簡體   English   中英

即使在頁面刷新后仍保留或將選中的單選按鈕設置為選中

[英]persisting or set checked radiobutton as checked even after page refresh

我有 4 個單選按鈕、一個文本框和一個搜索按鈕。 用戶選擇一個radiobtn,輸入關鍵字並點擊搜索。 按鈕的OnClick,單選按鈕值和輸入框值被抓取並作為查詢字符串傳遞給URL。 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並刷新頁面,一旦頁面刷新,它會將默認的“選中”重置為“全部”。 我想保持用戶檢查收音機的檢查 state 即使在刷新后。 可能嗎? 使用某種形式的 jquery?
基本上邏輯是這樣的,如果頁面 URL 是 mysite.com/event.aspx,則默認選中的 radioBtn 是“全部”,否則無論用戶選擇什么並作為查詢字符串傳遞給 URL

<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>

您可以將值存儲在cookie中,也可以使用sessionStorage

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM