简体   繁体   中英

persisting or set checked radiobutton as checked even after page refresh

I have 4 radio buttons and a textbox and a search button. User selects a radiobtn, types in keyword and clicks Search. OnClick of button, the radiobutton value and inputbox value is grabbed and passed to the URL as querystring. Like thishttp://mysite.com/event.aspx?kwd=keyword&type=radiobtnvalue If user selects Event, types in 'Dance' and hits SearchButton it would go to http://mysite.com/event.aspx?kwd=Dance&type=Event and refresh the page and once the page is refreshed it will reset the default 'checked' back to 'All'. I want to maintain the user checked radio's checked state even after refresh. Is it possible? using some form of jquery?
Basically the logic is like this, if Page URL is mysite.com/event.aspx, default checked radioBtn is "All" else whatever user selected and passed to the URL as querystring

<div class="EventRadios" style="color:#574319; font:13px Trebuchet">
    <input type="radio" name="EventType" value="" checked="checked"/>All &nbsp;  
    <input type="radio" name="EventType" value="Classes" />Class &nbsp;  
    <input type="radio" name="EventType" value="Events" />Event &nbsp;    
    <input type="radio" name="EventType" value="Support Groups" />Support Group&nbsp;&nbsp;<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>

you can store the value in cookie or as an alternative can use sessionStorage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM