Dear pros, I have 2 select option comboboxes on the form. One combo box reads data from mysql on pageLoad event.
OnChange of the selected option, php should read another data from mysql into the second combo box.
The second read-data should be in a function (not necessarily, just if there is a simpler way to do it). But please check the code below: Thank you!
Thank you!
OnChange of the selected option, php should read another data from mysql into the second combo box.
The second read-data should be in a function (not necessarily, just if there is a simpler way to do it). But please check the code below: Thank you!
Code:
<form name="form1" action="confirm_zone.php" method="post" style="margin-left:15px; margin-right:20px;">
<p><b style="color:#990000;">Select / Choose your Region:</b>
<?php
//this code reads first data from mysql and populate
//combo box 1.
//this is where the onChange event will come in.
$load_region = mysql_query("SELECT region_number FROM region ORDER BY region_number");
echo "<Select name='region' size='1' onChange='". read($data) ."'> ";//read($data) is a presumed function
while ($row = mysql_fetch_array($load_region)) {
echo '<option value="'. $row['region_number'] .'">' . $row['region_number'].'</option>'; }
echo "</select> ";
?>
<b style="color:#990000;">Select your Province:</b>
<?php
//this should be the function.
function read($data) {
$dropdown ="<Select name='province' size='1'> ";
$load_province = mysql_query("SELECT province_number, province_location FROM province ORDER BY province_number");
while ($row = mysql_fetch_array($load_province)) {
$dropdown .= "\r\n<option value='{$row['province_location']}'" . "-{$row['province_number']}>" ."{$row['province_location']}" . " {$row['province_number']}". "</option>"; }
$dropdown .= "\r\n</select>";
echo $dropdown."<br>";
}
?> <!-- end of function -->
Comment