Dynamic Dependent 3 Select Box using Jquery and Ajax -



Dynamic Dependent 3 Select Box using Jquery and Ajax -

i want dynamically select 3 select boxes class, section , subject. code using. here 2 select boxes loading properly, 3rd 1 subject not loading. help me this?

<!--ajax--> <script> function get_batch(course_id) { $("#loading").html('<img src="_layout/images/loading.gif"> loading...'); $.ajax({ type: "get", url: "get_batch.php", data: "cid="+course_id, success: function(msg){ $("#batch_div").html(msg); $("#loading").html(''); } }); } function get_subject(batch_id) { var cid=$("#course").val(); var bid=$("#batch").val(); $("#loading1").html('<img src="_layout/images/loading.gif"> loading...'); $.ajax({ type: "get", url: "get_subject.php", data: "cid="+cid+"&bid="+batch_id, success: function(msg){ $("#sub_div").html(msg); $("#loading1").html(''); } }); } </script> <!--get_batch.php--> <?php include("./mainclass.php"); $cid=$_request['cid']; ?><?php $sql_b=mysql_query("select * section class_id=$cid"); ?> <select name="section" id="section" style="width:300px;" onchange="get_student(this.value)"> <option selected="selected">select section</option> <?php while($row_b=mysql_fetch_object($sql_b)){ ?> <option value="<?php echo $row_b->id; ?>"><?php echo $row_b->section_name; ?></option> <?php }?> </select> <!--get_subject.php--> <?php include("./mainclass.php"); $cid=$_request['cid']; $bid=$_request['bid']; $sql_b=mysql_query("select * subjects class_id=$cid , section_id=$bid"); ?> <select name="subject" id="subject" style="width:300px; "> <option selected="selected">[select1 subject1]</option> <?php while($row=mysql_fetch_object($sql_b)){ ?> <option value="<?php echo $row->id; ?>"><?php echo $row->subject; ?></option> <?php }?> </select> <!-- html code--> <tr> <td height="48">class<span class="red">*</span></td> <td>:</td> <td><?php $sql_c=mysql_query("select * class"); ?> <select name="class" id="course" style="width:300px;" onchange="get_batch(this.value);" > <option selected="selected">select class</option> <?php while($row_c=mysql_fetch_object($sql_c)){ ?> <option value="<?php echo $row_c->id; ?>"><?php echo $row_c->class_name; ?></option> <?php }?> </select> <div id="loading"></div> <span class="red" id="course_error"></span></td> </tr> <tr> <td height="48"> section<span class="red">*</span></td> <td>:</td> <td><div id="batch_div"> <?php $sql_b=mysql_query("select * section"); ?> <select name="section" id="batch" style="width:300px;" onchange="get_exam(this.value);"> <option selected="selected">select section</option> <?php while($row_b=mysql_fetch_object($sql_b)){ ?> <option <?php echo $row_b->id; ?>><?php echo $row_b->section; ?></option> <?php }?> </select> </div> <span class="red" id="batch_error"></span> <div id="loading"></div></td> </tr> <tr> <td>subject<span class="red">*</span></td> <td height="48">:</td> <td colspan="2"><div id="sub_div"> <select name="subject" id="subject" class="normal" style=" width:300px;"> <option selected="selected">[select subject]</option> </select> </div> <span class="red" id="batch_error"></span></td> </tr>

jquery ajax select dynamic box

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -