title: Drop down menu on change do jquery function and sql query
body: <p>I am trying to get a sql query to run on drop down menu selection.  Here is what I have so far:</p>
  
  <pre><code>&lt;script&gt;
  $('#templateid').change(function(DoUpdateOnSelect) {
  $.post('page.edit.php?page_id=(--&gt;Need help in getting this id from the page url&lt;--)&amp;template='+this.options[this.selectedIndex].value);
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>And the drop down:</p>
  
  <pre><code>&lt;select name="templateid" id="templateid" onchange="DoUpdateOnSelect"&gt;
      &lt;option &gt;Contact&lt;/option&gt;
      &lt;option &gt;News&lt;/option&gt;
      &lt;option &gt;Home&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>page.edit.php has conditions on it which will run the sql query if it detects the page id and the template in the URL.  The template parameter value is grabbed with the jquery (please let me know if that part is set up wrong in the jquery) from the select drop down menu.  What I can't figure out is how to grab the page_id parameter from the current url of the page, and insert that into the function so that the page.edit.php?page_id=1&amp;template=Home will be the correctly outputted URL. </p>
  
  <p>Please let me know if you need further information.  Thanks in advance.</p>
  
  <p><strong>EDIT: BASED ON ANSWER BELOW:</strong></p>
  
  <pre><code>function querystring(name)
  {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&amp;]"+name+"=([^&amp;#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
  }
  $('#templateid').change(function() {
     var page_id = querystring('page_id');
     var url = '?VIEW=EDITPAGE&amp;linklabel='+page_id+'&amp;template='+(this.options[this.selectedIndex].value);
  $.post(url);
  });
  </code></pre>
  
  <p><strong>NO CHANGE IS HAPPENING WHEN I MAKE A SELECTION IN THE DROP DOWN MENU</strong></p>