hi guys...i need help from u guys..my prob is about select option..i'm not good in english. hopefully u guys would understand my english..:(..please help me..:'(..im still new in php..
i want to select a state then a branch will auto will appear if related..i only want if one state is choose, only the branch of the state will appear. not all branch will appear together.
Question:
1) how to make it success?
2) i have use onchange event. but i doesn't work! so would i do?
3) where do i put the onchange event? where do i put the function of onchange event?
4) how to write a function related to state and branch?
this code for NEGERI - state
<select name="NEGERI" class="select" id="NEGERI" onchange="myFunction(this.value)">
<option value ="0">-- Sila Pilih --</option>
<?
//$sql = "SELECT * FROM negeri where FLAG=1 ORDER BY negeri ASC";
$sql = $sql = "SELECT * FROM negeri WHERE negeri_id ='".$negeri."' FLAG=1 ORDER BY negeri ASC";
$result_groups = mysql_query($sql);
$result_group_member = mysql_num_rows ($result_groups);
if($result_group_number > 0) {
while ($myrow = mysql_fetch_array($result_group)) {
if ($negeri == $myrow["negeri_id"])
echo "<option value = ".$myrow["negeri_id"]." selected > ".$myrow["negeri"]."</option>\n";
else "<option value =".$myrow["negeri_id"].">".$myrow["negeri"]."</option\n";
}
}
?></td>
</tr>
<tr>
<td height="21" bgcolor="#D0F0C0" class="style21"></td>
<td bgcolor="#D0F0C0" class="style21"><div align="left"><b>Cawangan</b></div></td>
<td bgcolor="#D0F0C0" class="style21"><b>:</b></td>
<td bgcolor="#D0F0C0">
<?
$sql = "SELECT * FROM negeri_cawangan WHERE cawangan_id = '".$CAWANGAN."' FLAG=1 ORDER BY cawangan ASC";
$result_groups = mysql_query($sql);
$result_group_number = mysql_num_rows($result_groups);
if($result_group_number > 0) {
while ($myrow = mysql_fetch_array($result_groups)) {
$kod=$myrow['kod'];
$cawangan=$myrow['cawangan'];
$cawangan_id=$myrow['cawangan_id'];
//if (isset($somevariable) && $somevariable === 1) {
if ($cawangan == $myrow["cawangan_id"]) {
echo "<option value=".$myrow["cawangan_id"]." selected > ".$myrow["cawangan"]."</option>\n";
else
echo "<option value = ".$myrow["cawangan_id"]." > ".$myrow["cawangan"]."</option>\n";
}
}
?>
this code for CAWANGAN = branch
<select name="NEGERI" class="select" id="NEGERI" onchange="myFunction(this.value)">
<option value ="0">-- Sila Pilih --</option>
<?
//$sql = "SELECT * FROM negeri where FLAG=1 ORDER BY negeri ASC";
$sql = $sql = "SELECT * FROM negeri WHERE negeri_id ='".$negeri."' FLAG=1 ORDER BY negeri ASC";
$result_groups = mysql_query($sql);
$result_group_member = mysql_num_rows ($result_groups);
if($result_group_number > 0) {
while ($myrow = mysql_fetch_array($result_group)) {
if ($negeri == $myrow["negeri_id"])
echo "<option value = ".$myrow["negeri_id"]." selected > ".$myrow["negeri"]."</option>\n";
else "<option value =".$myrow["negeri_id"].">".$myrow["negeri"]."</option\n";
}
}
?></td>
</tr>
<tr>
<td height="21" bgcolor="#D0F0C0" class="style21"></td>
<td bgcolor="#D0F0C0" class="style21"><div align="left"><b>Cawangan</b></div></td>
<td bgcolor="#D0F0C0" class="style21"><b>:</b></td>
<td bgcolor="#D0F0C0">
<?
$sql = "SELECT * FROM negeri_cawangan WHERE cawangan_id = '".$CAWANGAN."' FLAG=1 ORDER BY cawangan ASC";
$result_groups = mysql_query($sql);
$result_group_number = mysql_num_rows($result_groups);
if($result_group_number > 0) {
while ($myrow = mysql_fetch_array($result_groups)) {
$kod=$myrow['kod'];
$cawangan=$myrow['cawangan'];
$cawangan_id=$myrow['cawangan_id'];
//if (isset($somevariable) && $somevariable === 1) {
if ($cawangan == $myrow["cawangan_id"]) {
echo "<option value=".$myrow["cawangan_id"]." selected > ".$myrow["cawangan"]."</option>\n";
else
echo "<option value = ".$myrow["cawangan_id"]." > ".$myrow["cawangan"]."</option>\n";
}
}
?>
`