Click here to Skip to main content
11,705,610 members (51,684 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript PHP
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?

<?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
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 17-Jan-13 18:54pm
Edited 17-Jan-13 18:56pm
v2
Comments
Kislay Raj at 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)

  Print Answers RSS
0 OriginalGriff 229
1 Sergey Alexandrovich Kryukov 100
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100