I have MySQL tables looking like that
regions table
id | region
-------------------
1 | Region1
2 | Region2
...
and schools table
id | school
-------------------
1 | schno1
1 | schno5
1 | schno6
2 | scho120
There are multiple select (dropdown) menus in my registration form. The regions dropdown looks like that
<select name="region">
<option value="0">Select the region</option>
<?php
$result=$db->query("SELECT * FROM regions");
while($row=$result->fetch_array(MYSQLI_BOTH))
{
echo '<option value="'.$row[0].'">'.$row[1].'</option>';
}
?>
</select>
What i want to do is, get "regions" id, then populate schools dropdown menu based on id (id of previous selection) from "schools" table on the fly. I'm newbie to js. Please help me to fix it. Thx in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…