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";
                        }
                        }
                        ?>

`

As I understood, you want to have nested combo boxes where the child combo box gets repopulated when the parent combo box gets changed.
I am sorry if I misunderstood your question.

my question is about how to make a state select then the branch will appear together if related?
for state it will become --> JOHOR MELAKA KEDAH..etc

for branch has it own code and name also..for example --> 01011021 YONG PENG 01041011 KOTA TINGGI

SO NOW IT WOULD BE HAS 2 COMBO BOXES..ONE FOR STATE(NEGERI) & BRANCH(CAWANGAN)

the 'state' also have own code eg: KEDAH (02), JOHOR (01)...so from the code it would call code from the 'branch'..but i do not know how to use and call the onchange event?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.