1

I have two dropdowns .i want second dropdown list shoul changed according to the value selected in first dropdown.

this is my first dropdown

Category :<select name="Category" id="a1_txtBox5" required="required">
                       <option value="select">select..</option>
                       <?php while($selectcategoryarray=mysql_fetch_array($selectcategory)) {
                       ?>
                        <option value="<?php echo $selectcategoryarray[1];?>"><?php echo $selectcategoryarray[1];?></option>
                        <?php
                        }
                        ?>
                    </select>

And here is my second dropdown:

<label style="margin-left:24px;">Subcategory :</label><select style="margin-right:35px;" name="subcategory" id="a1_txtBox3" required="required">
                        <option value="select"> select..</option>
                        <?php while($selectsubcategoryarray=mysql_fetch_array($selectsubcategory)) {
                       ?>
                        <option value="<?php echo  $selectsubcategoryarray[2];?>"><?php echo $selectsubcategoryarray[2];?></option>
                        <?php
                        }
                        ?>
                    </select>

Please help.

  • you need to ajax and php for do this try simple way http://stackoverflow.com/questions/18207689/2nd-dropdown-list-based-on-the-value-of-first-drop-down-list – Rakesh Sharma Dec 11 '13 at 10:22

1 Answers1

0

Exactly you need to handle the Change Event for your first Select element and in the body of the event you need to send request to server for getting data of second Select element. I recommend to use an ajax process to doing this. And o this you should use jQuery for handling events and have ajax.

Saman Gholami
  • 3,416
  • 7
  • 30
  • 71