I have a dropdown list with id='apha'
with three options and their values are comma separated.
<select class="browser-default" id="alpha">
<option value="a,b,c">One</option>
<option value="d">Two</option>
<option value="e,f">Three</option>
</select>
Another dropdown beta
with values. Based on which option is selected in alpha
those values should be there in second dropdown beta
.
<select class="browser-default" id="beta">
<option value="a">First</option>
<option value="b">Second</option>
<option value="c">Third</option>
<option value="d">Fourth</option>
<option value="e">Fifth</option>
<option value="f">Sixth</option>
</select>
So if One
is selected from alpha
dropdown. Only values of aplha
- a,b,c
should be present in beta
dropdown - First Second Third
What i have tried: Without comma separated in values
$('#alpha').on('change', function () {
$('#alpha').html('');
if ($('#alpha').val() == "One") {
$('#alpha').append('<option value="a">First</option>');
$('#alpha').append('<option value="b">Second</option>');
$('#alpha').append('<option value="c">Third</option>');
}
});