DSTR3 Posted January 18, 2013 Share Posted January 18, 2013 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 More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 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 More sharing options...
DSTR3 Posted January 18, 2013 Author Share Posted January 18, 2013 Thank you. Yes I tried various things. All met with failure.! These are two different values. How do I do this? Your help is greatly appreciated. Thank you. I need two different values. Lid and Cid. Link to comment https://forums.phpfreaks.com/topic/273327-pulling-two-values/#findComment-1406754 Share on other sites More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 Read the links in my signature about how to get good help. What did you try? If they are two different values, why are you assigning them from the same value? Link to comment https://forums.phpfreaks.com/topic/273327-pulling-two-values/#findComment-1406755 Share on other sites More sharing options...
DSTR3 Posted January 18, 2013 Author Share Posted January 18, 2013 It really doesn't matter what I tried, because nothing worked. How do I assign two different values? Thank you. Link to comment https://forums.phpfreaks.com/topic/273327-pulling-two-values/#findComment-1406756 Share on other sites More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 With an equals sign and then two different values. Link to comment https://forums.phpfreaks.com/topic/273327-pulling-two-values/#findComment-1406758 Share on other sites More sharing options...
DSTR3 Posted January 18, 2013 Author Share Posted January 18, 2013 Do you mean like this? var LocationString = 'Lid='+ $(this1).val(); var CityString = 'Cid='+ $(this2).val(); or this? ] var LocationString = 'Lid='+ $(this).val(); var CityString = 'Cid='+ $(this).va2l(); ] Link to comment https://forums.phpfreaks.com/topic/273327-pulling-two-values/#findComment-1406760 Share on other sites More sharing options...
DSTR3 Posted January 19, 2013 Author Share Posted January 19, 2013 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.