I am setting up a conditional dropdown.
<div class="form-group">
<label asp-for="son" class="control-label"></label>
<select name="son" id="son">
<option value="none" class="a" selected="selected"> -- choose one --</option>
<option>Yes</option>
<option>No</option>
</select>
<span asp-validation-for="son" class="text-danger"></span>
</div>
Here is the dropdown for son, if it is NO then then the below 1st dropdown must come.
<div id="fatherNo" style="display: none" class="form-group">
<label asp-for="NO" class="control-label"></label>
<select name="NO">
<option value="none" class="a" selected="selected"> -- choose one --</option>
<option>Not_Applicable</option>
</select>
<span asp-validation-for="No" class="text-danger"></span>
</div>
If it is Yes in the son dropdown then then the below 2nd dropdown must come.
<div id="fatheryes" style="display: none" class="form-group">
<label asp-for="fatheryes" class="control-label"></label>
<select name="fatheryes">
<option value="none" class="a" selected="selected"> -- choose one --</option>
<option>working</option>
</select>
<span asp-validation-for="fatheryes" class="text-danger"></span>
</div>
2
Answers
When son select is change, This function be play
as you mention jQuery in your tags, it is implemented by jQuery. Please use a dropdown
library for convenient.
Any way check snippet below: