title: set checkboxes checked after page refresh based on checkboxes values in the URL querystring
body: <p>I have a set of checkboxes:</p>
  
  <pre><code>    &lt;input name="LocType" type="checkbox" value="Hospital"/&gt;HOSPITALS&amp;#160;&amp;#160;
      &lt;input name="LocType" type="checkbox"  value="Office"/&gt;  PHYSICIAN OFFICES&amp;#160;&amp;#160;
      &lt;input name="LocType" type="checkbox"  value="Emergency"/&gt;EMERGENCY CENTERS&amp;#160;&amp;#160;
      &lt;input name="LocType" type="checkbox"  value="Out-Patient"/&gt;OUT-PATIENT CENTERS&amp;#160;&amp;#160;
      &lt;input name="LocType" type="checkbox" value="Facility"/&gt;FACILITIES
  </code></pre>
  
  <p>I have grabbed their values as follows and passed to the url, after page reloads with the passed querystring, i wanna check for whatever checkboxes values were passed and set those checkboxes to checked=true.</p>
  
  <pre><code>var url = "http://mysite.com/contact-us/Pages/LocationSearch.aspx?s=bcs_locations&amp;k=";     
  var checkboxValues = $("input[name=LocType]:checked").map(function() {
      return ' '+'bcslocationtype:'+"\"" + $(this).val() + "\"";}).get().join(" OR ");                 
  
           window.location= url +  checkboxValues;
  </code></pre>
  
  <p>When Hospitals and Emergency checkboxes are checked and hit search, URL looks like this:
  <a href="http://mysite.com/contact-us/Pages/LocationSearch.aspx?s=bcs_locations&amp;k=" rel="nofollow">http://mysite.com/contact-us/Pages/LocationSearch.aspx?s=bcs_locations&amp;k=</a> bcslocationtype:"Hospital" OR  bcslocationtype:"Emergency"        </p>
  
  <p>Now why is thing not working, I don't see anything wrong with this?its insde document.ready(){}   </p>
  
  <pre><code>//Keep the selected chkboxes checked on page redirect
      var value = window.location.href.match(/[?&amp;]k=([^&amp;#]+)/) || [];
      if (value.length == 2) {
          $('input[name=LocType]').each(function (index) {
              if(value[1].indexOf($(this).val())&gt;=0)
                  this.prop("checked", true); 
              }); 
      }  
  </code></pre>