Jump to content

Pulling Two Values


DSTR3

Recommended Posts

I have code that is working.

 

$('.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);

 

However; I need two values. Lid (LocationString) and Cid (CityString) How would I do this? I tried this and it doesn't work.

 

$('.Kitty').live("change",function(){
var LocationString = 'Lid='+ $(this).val();
var CityString = 'Cid='+ $(this).val();
   $.ajax({
    type: "POST",
    url: "ajax_area.php",
    data: {Lid: LocationString, Cid:CityString},
    cache: false,
    success: function (html) {		   
$(".Pig").html(html);

 

And this is the ajax_area.php file. Its grabbing Lid successfully, how is Cid added to this mix?

 

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

 

Help is appreciated! Thank you!

Link to comment
https://forums.phpfreaks.com/topic/273327-pulling-two-values/
Share on other sites

You have $Lid=$_POST['Lid']; and you're asking how you would get the posted value of Cid as well? ..... Did you try anything yet?

 

Regardless they'll be the same value.

var LocationString = 'Lid='+ $(this).val();
var CityString = 'Cid='+ $(this).val();

.

Link to comment
https://forums.phpfreaks.com/topic/273327-pulling-two-values/#findComment-1406752
Share on other sites

Solved!

 

$(document).ready(function()
{
$(".Doggie").change(function()
{
var LocationString ='Rid='+ $(this).val();
   $.ajax({
    type: "POST",
    url: "place_city.php",
    data: LocationString,
 cache: false,
    success: function (html) {
	    $(".Kitty").html(html);
    }
   });
});
$('.Kitty').live("change",function(){
var Rid = $('#Doggie').val(),  // This is the value of the id="Doggie" selected option
   Cid = $(this).val(); // This is the value of the id="Kitty" selected option
//alert("Rid = " + Rid + " Cid = " + Cid);
$.ajax({
    type: "POST",
    url: "place_area.php",
    data: {"Rid":Rid,"Cid":Cid},
    cache: false,
    success: function (html) {
  //alert('This is what is returned from the php script: ' + html);			
$(".Pig").html(html);
}
});
});
});

Link to comment
https://forums.phpfreaks.com/topic/273327-pulling-two-values/#findComment-1406956
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.