How to used drop down list more than 3 used ajax php

Description

How to used Dynamic Dependent drop down Select Box using jQuery, Ajax and PHP

Dropdown Based on Selection show content used more than three used ajax php mysql

 

Dependent dropdown seelct using jquery ajax php mysql 3 level

how to implement and use work in php mysql code

 

First Step we can select the drop down option and select id pass to another php file and show drop down

2nd step On click first select div id and than select drop down ID show and pass to another file (followuallroomshowlist.php)

3rd step Get id (followupselectbatchsubject.php) show drop down

 

 

<!---------Select first room and than batch option First Drop down -----------> 

 <script>  

 $(document).ready(function(){  

      $('#roomselectmg').click(function(){ 

  //alert("Whyunoalert?");

        var txtsub = $("#roomselectmg").val(); 

//alert(txtsub);

$.ajax({  

                     url:"followuallroomshowlist.php",  

                     type:"post", 

data:"roomselectmg="+txtsub+"", 

                    success:function(data)  

                     {  

                          $('#roomshowselect').html(data);  

                     }  

                });  

            

          

      });  

 });  

 </script>

 <!---------Select subject first option----------->    

 

 

 <!---------Select batch coursee with subject option 2nd drop down option Drop down -----------> 

 <script>  

 $(document).ready(function(){  

      $('#roomshowselect').click(function(){ 

//  alert("Whyunoalert?");

        var txtsub = $("#managelistshowadd").val(); 

// alert(txtsub);

$.ajax({  

                     url:"followupselectbatchsubject.php",  

                     type:"post", 

data:"roomselectmg="+txtsub+"", 

                    success:function(data)  

                     {  

                          $('#showbatchsubjectselect').html(data);  

                     }  

                });  

            

          

      });  

 });  

 </script>

<!---------Select batch coursee with subject option----------->  

 

 

Select Room First Drop down

 

                    <div class="form-group">    

<label class="control-label" for="inputSuccess1">Select Room : &nbsp &nbsp &nbsp   </label> 

<label class="control-label" for="inputSuccess1" style="width:80%">

<select class="form-control" name="room" id="roomselectmg">

<option value="all,all">Select Room</option>

<?php

$showst=mysql_query("Select * from selectroom order by id desc");

while($rowlinkst=mysql_fetch_array($showst)){?> 

<option value="<?php echo $rowlinkst['id']; ?>,<?php echo $rowlinkst['roomname']; ?>"><?php echo $rowlinkst['roomname']; ?></option>

<?php } ?>

</select>

 </label>

</div>

 

  First drop downoutput in Id

<div id="roomshowselect"></div>

 

 2nd Div show in ID

<div id="showbatchsubjectselect"></div>

 

Ajax file

 

 

 First drop downoutput in Id pass with ajax followuallroomshowlist.php

 

 

   <?php

$roomselectmg =  $_POST['roomselectmg']; 

echo $roomselectmg;

$roomselectmgc = explode(",", $roomselectmg);

    $roomselectmgcid = $roomselectmgc[0];

$roomselectmgcname = $roomselectmgc[1];

//echo  "SELECT * FROM topic where subid = '".$topicselectid."'";

    ?>

 

 

     <select class="form-control" id="managelistshowadd" name="manageselect" >

     <option value=""> Select Batch </option>

<?php

$showst=mysql_query("Select * from managebatchtimeadd");

while($rowlinkst=mysql_fetch_array($showst)){?>  

         <option value="<?php echo $rowlinkst['id']; ?>,<?php echo $rowlinkst['managebatchname']; ?>"><?php echo $rowlinkst['managebatchname']; ?> </option>

<?php } ?>

    </select>

 

 

 

   2nf drop down output pass id with ajax followupselectbatchsubject.php

 

    <?php

$roomselectmg =  $_POST['roomselectmg']; 

echo $roomselectmg;

$roomselectmgc = explode(",", $roomselectmg);

    $roomselectmgcid = $roomselectmgc[0];

$roomselectmgcname = $roomselectmgc[1];

//echo  "SELECT * FROM topic where subid = '".$topicselectid."'";

    ?>