<?php require('config.php'); ?> //This is based on Place, City, Area $(document).ready(function() { $(".Doggie").change(function() { var LocationString = 'Lid='+ $(this).val(); $.ajax({ type: "POST", url: "ajax_city.php", data: LocationString, cache: false, success: function (html) { $(".Kitty").html(html); } }); }); $('.Kitty').live("change",function(){ var LocationString = 'Lid='+ $(this).val(); $.ajax({ type: "POST", url: "ajax_area.php", data: LocationString, cache: false, success: function (html) { $(".Pig").html(html); } }); }); }); </script> </head> <body> <div id="frame1"> <label>Place :</label> <select name="Doggie" class="Doggie" id="Doggie"> <option selected="selected">--Select Place--</option> <?php $sql = mysql_query("SELECT tblLocations.RestID as Lid, tblRestaurants.RestName as name FROM tblRestaurants INNER JOIN tblLocations ON tblRestaurants.RestID = tblLocations.RestID GROUP BY tblLocations.RestID, tblRestaurants.RestName ORDER BY tblRestaurants.RestName ASC"); while($row=mysql_fetch_array($sql)) { echo '<option value="'.$row['Lid'].'">'.$row['name'].'</option>'; } ?> </select> <label>City :</label> <select name="Kitty" class="Kitty" id="Kitty"> <option selected="selected">--Select City--</option> </select> <label>Area: :</label> <select name="Pig" class="Pig" id="Pig"> <option selected="selected">--Select Area--</option> </select> </div> </body> </html>
<?php require('config.php'); if($_POST['Lid']) { $Lid=$_POST['Lid']; $sql=mysql_query("SELECT tblLocations.RestID as LID, tblAreas.AreaName as name FROM tblLocations INNER JOIN tblAreas ON tblLocations.AreaID = tblAreas.AreaID WHERE tblLocations.RestID = $Lid GROUP BY tblLocations.RestID, tblAreas.AreaName ORDER BY tblAreas.AreaName ASC"); echo '<option selected="selected">--Select Area--</option>'; while($row=mysql_fetch_array($sql)) { echo '<option value="'.$row['Lid'].'">'.$row['name'].'</option>'; } } ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)