php - second dropdown is not fill when selecting fisrt dropdown value -
i have 2 table ,
- state stcode, statename
2.district distcode, stcode, districtname
my code first drop down
<td><label for="studentstate"></label> <select name="studentstate" id="studentstate"> <?php $con=mysql_connect("localhost","root",""); if(!$con) { die('could not connect:'.mysql_error()); } mysql_select_db("db_loan",$con); $sqlstr="select stcode,statename state"; $result=mysql_query($sqlstr); while($row=mysql_fetch_array($result)) { echo '<option value="'.$row['stcode'].'">'.$row['statename'].'</option>'; } echo $sccode=$row['stcode']; ?> </select></td>
now have try following second dropdownlist want show district name
<div id="result"> <input type="button" value="reload"></input> <select name="studentdist" id="studentdist"> <?php $con=mysql_connect("localhost","root",""); if(!$con) { die('could not connect:'.mysql_error()); } mysql_select_db("db_loan",$con); $sqlstr="select distcode,districtname district stcode='$sccode'"; $result=mysql_query($sqlstr); while($row=mysql_fetch_array($result)) { echo '<option value="'.$row['distcode'].'">'.$row['districtname'].'</option>'; } // echo $sccode=$row['distcode']; ?> </select></td> </div>
now if should reload div when select first value drop down list
please if know please tell me how without using ajex or jquery
after read suggestion mirza have updated code follow still there not working
</head> <script type="text/javascript"> $("#studentstate").change(function() { $("#studentdist").load("pag1.php?choice=" + $("#studentstate").val()); }); </script> <body>
you need jquery basic task
<script type="text/javascript"> $("#first-choice").change(function() { $("#second-choice").load("getter.php?choice=" + $("#first-choice").val()); }); </script>
getter.php replace php page name , work
Comments
Post a Comment