Click here to Skip to main content
15,896,358 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
I have this script that works very well so far, however; its come to light that I need two values passed along. Not just one. Right Now I am passing the RestID from the tblLocations. I also need the CityID from the same table. How can I pass the two values along?

JavaScript
<?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>


And one of the PHP files

PHP
<?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>';
}
}

?>
Posted
Updated 17-Jan-13 18:56pm
v2
Comments
Kislay Raj 18-Jan-13 7:22am    
make it more clear so that i can answer you. what do you want mean to say do call both from same php file? or in same function where do you want to send both data mean from php file to that via ajax or other i am waiting for your reply

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900