Jump to content

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();

.

Edited by Jessica
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.