I want when user select yes or no then other input fields appear but in my case the one field is appear without selecting no, I want that field appear only when user select no
<script>
$(document).ready(function() {
toggleFields();
$("#selection").change(function() {
toggleFields();
});
});
function toggleFields() {
if ($("#selection").val() == 156)
$("#Distance").show();
else
$("#Distance").hide();
if ($("#selection").val() == 156)
$("#closest").hide();
else
$("#closest").show();
}
</script>
<tr>
<td style="width: 50%">
<label for = "section"><b> Are you using Optimap? *</b></label><br><br>
<select id="selection" name="selection" style="width: 320px; height: 35px; border-radius: 8px" required>
<option value="" disabled selected > Please Select... </option>
<option value="156"> Yes</option>
<option value="160"> No </option>
</select>
<br><br>
</td>
<td style="width: 50%" id = "closest" style="display: none;">
<label for="closest"><b>The Distance between the center of two closest PCB's in mm *</b></label><br><br>
<input type = "number" step="any" name = "closest" style="width: 320px; height: 25px; border-radius: 8px" required /><br><br>
</td>
<td style="width: 50%">
<div id = "Distance" style="display: none;">
<label for="stance"><b>The Distance between the center of two closest Optimaps in mm *</b></label><br><br>
<input type = "number" step="any" name = "Distance" style="width: 320px; height: 25px; border-radius: 8px" required /><br><br>
</td>
</tr>