remembering of a select menu option with jquery
<p>Hello to everybody and thanks in advance for reading this...
I have 4 dynamically dependent select menus. The menus correspond to state, county, area, neighborhood. The dynamic dependence is achieved through a jquery script.What i want to accomplish is to make the menus remember the last option selected by a user for each menu. So i thought that if i can grab the url parameters that would do the trick.
So i modified the script in this way....</p>

<pre><code>getCounty: function (results) {
    if(!results) return;
    var allCounties = $("&lt;option value=\"All\"&gt;All Counties &lt;/option&gt;");
    counties.html(results);
    counties.prepend(allCounties);
    var w = $.query.get("county_id");
    if(w) {
        counties.val(w).attr('selected', true);
    } else {
        counties.val("All").attr('selected', true);
    }
</code></pre>

<p>Is the <code>$.query.get</code> function correct? Is there anything else wrong with my code? I have to admit i am not a jquery expert...The code works just fine if i type</p>

<pre><code>counties.val(3).attr('selected',true)
</code></pre>

<p>The third option of the select menu gets selected.
Any suggestion will be highly appreciated!! </p>

<p>Ok i resolved the problem by using </p>

<pre><code>function getUrlVars() {
  var vars = {};
  var parts = window.location.href.replace(/[?&amp;]+([^=&amp;]+)=([^&amp;]*)/gi,   function(m,key,value) {
    vars[key] = value;
  });
  return vars;
}
</code></pre>

<p>And after</p>

<pre><code>  var county = getUrlVars()["county_id"];

  if (county)    
     counties.val(county).attr('selected',true);
  else 
      counties.val("All").attr('selected',true);
</code></pre>
