My HTML code
Transportation:
<input type="radio" name="transportation" value="BUS"> Bus </option><br>
<input type="radio" name="transportation" id="khaschkbox" value="KHAS">Khas</option><br>
Bus:
<select id="busDropdown" name="bus">
<option value="Null"> NA </option>
<?php
$sql = "SELECT busNumber FROM Bus";
$result = $conn->query($sql);
$row_count = $result->rowCount();
if ($row_count > 0){
while ($row = $result->fetch())
{
echo "<option value=".$row['busNumber'].">".$row['busNumber']."</option>";
}
}
?>
</select><br><br>
in my jQuery, if the user checked Khas, the dropdown list will be disabled. that works. but the problem if the user chose khas then Bus the dropdownlist will remain disabled which is wrong!
JQuery:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
$(function() {
$("#khaschkbox").change(function(){
if(this.checked){
$("#busDropdown").prop("disabled",true);
} else {
$("#busDropdown").prop("disabled",false);
}
});
});
I need the list to appear when the user choose Bus and disappear if he chose Khas. How can I fix that?