title: drop down selection page reload function for multiple variables
body: <p>I am working on a piece of code that will display the content of a mysql query in a template, since the query could feasibly return hundreds of results Ive included a page limiter and navigation tool. Unfortunately I am having a problem passing the page number after I select the number of results to show per page. The page nav is separate and working fine except it cant see the page number once this function has run.</p>
  
  <pre><code>&lt;script&gt;
  function refreshpage(results_per_page){
  window.location="classifieds.php?&amp;results_per_page="+results_per_page
  }
  &lt;/script&gt;
  
  &lt;?php
  $results_per_page = $_GET['results_per_page'];   
  
  ?&gt;
  &lt;select onchange="refreshpage(this.value);"&gt;
  &lt;option selected value="&lt;?php echo $results_per_page?&gt;"&gt;&lt;?php echo $results_per_page?&gt;&lt;/option&gt;
        &lt;option value="1"&gt;1&lt;/option&gt;
        &lt;option value="2"&gt;2&lt;/option&gt;
        &lt;option value="3"&gt;3&lt;/option&gt;
        &lt;option value="4"&gt;4&lt;/option&gt;
        &lt;option value="5"&gt;5&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>The above code works fine and automatically reloads the page, but when ever i try to introduce a $page variable the pageRefresh function fails to work. Is this the right way to go about what I am after or is there another way that will let me include another variable. All it needs to be is;</p>
  
  <pre><code>$page;
  </code></pre>
  
  <p>taken from the url</p>
  
  <pre><code> $page = $_GET['page'];     
  </code></pre>
  
  <p>Ive tried sending it with the onchange function, calling it from within the refreshPage Function, even using an intermediate function to assemble an extension with all the relevant data and nothing seems to give the result.</p>
  
  <p>Thanks</p>
  
  <p>EDIT:</p>
  
  <p>Thanks to sasse, I got enough Info to correct the code I believe. This seems to now work so if anyone else has had this issue, this seems to be a good work around. Thanks! (never occurred to me to use val!)</p>
  
  <pre><code>&lt;script&gt;
  function refreshpage(results_per_page){
  var page = &lt;?php echo $_GET['page'] ?&gt;;
  window.location="classifieds.php?page=" + page + "&amp;results_per_page="+results_per_page
  }
  &lt;/script&gt;
  
  &lt;?php
  $results_per_page = $_GET['results_per_page'];   
  
  ?&gt;
  &lt;select onchange="refreshpage(this.value);"&gt;
  &lt;option selected value="&lt;?php echo $results_per_page?&gt;"&gt;&lt;?php echo $results_per_page?&gt;&lt;/option&gt;
        &lt;option value="1"&gt;1&lt;/option&gt;
        &lt;option value="2"&gt;2&lt;/option&gt;
        &lt;option value="3"&gt;3&lt;/option&gt;
        &lt;option value="4"&gt;4&lt;/option&gt;
        &lt;option value="5"&gt;5&lt;/option&gt;
  &lt;/select&gt;         
  </code></pre>