Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could define your variable <code>searchRooms</code> as a global (or some other suitable enclosing scope), outside of the scope of your <code>.change</code> function and it would be available when you do you AJAX call. Alternatively, you can just grab the values you need when you do your AJAX call exactly the same way you are doing it in your <code>.change</code> function. </p> <p>In fact, as it stands right now, your <code>.change</code> function is doing nothing useful. You are grabbing the value from <code>#rooms</code> and putting it in a local variable that goes immediately out-of-scope. So it's not clear what you were trying to do there anyway. </p> <p>So, you could do this:</p> <pre><code>var searchRooms; $("#rooms").change(function () { searchRooms = $("#rooms").val(); }); </code></pre> <p>Or, better, you could just do this:</p> <pre><code>$("#mybutton").click(function() { var searchRooms = $("#rooms").val(); var myotherdropdown = $("#otherdropdown").val(); // now do your AJAX call, passing in your variables you grabbed above. $.ajax(//..... }); </code></pre> <p><em>Update</em>: Something like this:</p> <pre><code>var searchRooms; var searchAdults; var searchChildren; $("#rooms").change(function () { searchRooms = $("#rooms").val(); }); $("#adults").change(function () { searchAdults = $("#adults").val(); }); $("#searchChildren").change(function () { searchChildren = $("#children").val(); }); $(#"btn").click(function(){ // How you pass the data here will depend on what you are calling and what format it's expecting. It *might* look something like this... $.ajax({ data: { "searchRooms" : searchRooms, "searchAdults" : searchAdults, "searchChildren": searchChildren }, // all your other settings for this ajax call... }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload