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! Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 (edited) 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 January 18, 2013 by Jessica Quote Link to comment Share on other sites More sharing options...
DSTR3 Posted January 18, 2013 Author Share Posted January 18, 2013 (edited) 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. Edited January 18, 2013 by DSTR3 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
DSTR3 Posted January 18, 2013 Author Share Posted January 18, 2013 (edited) 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(); ] Edited January 18, 2013 by DSTR3 Quote Link to comment 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); } }); }); }); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.