I have two <select>
, Categories and Subcategories.
I want when i click an option/value from Categories then load & update the second <select>
from mySQL. Subcategories values are in mySQL.
(1) Category Select
<select class="form-control" onchange="check()" id="category" name="category">
<option value="cafe">Café</option>
<option value="bars-clubs">Bars-Clubs</option>
<option value="restaurants">Restaurants</option>
<option value="shopping">Shopping</option>
<option value="services">Services</option>
<option value="sducation">Education</option>
</select>
(2) Subcategory Select
<select class="form-control " id="SubCategory" name="subCategory">
<?php include "server.php";
$qyerry = "select * from " + [[FROM CATEGORY VALUE]]
$result = mysql_query($qyerry);
while($row = mysql_fetch_array($result)){
echo "<option value=''>" . $row{'name'} . "</option>";
}
?>
</select>
Here is my Javascript Code to get the value of onchange value option
<script>
function check(){
var x = document.getElementById("category").value;
}
</script>