Grab URL parameters to maintain search form options using jQuery or javascript -


i have set of search filters set url string (for further processing). page reloads show results, options selected user lost. wondering if it's possible use jquery capture parameters url , 'remember' options had been selected?

for example, if url contained www.something.com/index.html?&colour=red&circle=1&star=0, form load following:

<h3>colour</h3> <p>blue: <input name="colour" type="radio" value="blue" /></p> <p>red: <input name="colour" type="radio" value="red" /></p> [selected] <p>green: <input name="colour" type="radio" value="green" /></p>  <h3>shape</h3> <p>circle: <input name="circle" type="checkbox" value="1" /></p> [selected] <p>square: <input name="square" type="checkbox" value="1" /></p> <p>star: <input name="star" type="checkbox" value="1" /></p> 

thanks looking.

<script type="text/javascript"> function getquerystr(name) {     hu = window.location.search.substring(1);     gy = hu.split("&");     (i=0;i<gy.length;i++) {         ft = gy[i].split("=");         if (ft[0] == ji) {             return ft[1]; }}}  $(document).ready(function() {     $('input[name=color]').val(getquerystr("colour"));     $('input[name=circle]').prop("checked", (getquerystr("circle")=="1"));     $('input[name=square]').prop("checked", (getquerystr("square")=="1"));     $('input[name=star]').prop("checked", (getquerystr("star")=="1")); }); </script> 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -