you could use the .serialize() method :
var queryString = $('#myForm').serialize();
which would give you something like :
EventType=All&KeywordBox=blablabla
you could then load the page you want like so :
document.location ='http://myschool.com/event.aspx?'+queryString;
Summary :
<formid="myForm" method="GET"><div class="EventRadios" style="color:#574319;font:13px Trebuchet"> <input type="radio" name="EventType" value="All"/>All <input type="radio" name="EventType" value="Class"/>Class <input type="radio" name="EventType" value="Event"/>Event <input type="radio" name="EventType" value="Support Group"/>Support Group <br/><br/> </div> <input name="KeywordBox" class="BasicSearchInputBox" type="text" value="Keyword Search..."/> <div class="searchBtnHolder"><a class="searchButton" href="#"type="submit"><span>Search</span></a></div></form> <scripttype="text/javascript"> $('.searchButton').click(function(ev){ var queryString = $('#myForm').serialize(); document.location ='http://myschool.com/event.aspx?'+queryString; }); </script>
simple answer to your question is grab all your form value and make url string with your value and send to location.href = " your url + value ";
$(".searchButton").click(function(){ var radioVal = $('input:radio[name=EventType]:checked').val(); var textVal = $("input:text[name=keywordBox]").val(); value ="r="+ radioVal +"&t="+ textVal; location.href ="yourURL"+ value; });
原文地址:http://stackoverflow.com/questions/8645861/add-querystring-to-url-on-buttonclick-jquery