[英]deselect struts2 select from javascript
如何從JavaScript中取消選擇struts2選擇列表?
例如。
<s:select name="bookIds" list="bookList" listKey="key"
listValue="value" multiple="true" theme="simple"
onchange="getVal(this.options[this.selectedIndex].value,'myvalue');"/>
我想在onchange事件之后取消選擇所有列表。
聲明headerKey
和headerValue
<s:select id="book_select" name="bookIds" list="bookList" listKey="key"
headerKey="-1" headerValue="Select Book"
listValue="value" multiple="true" theme="simple"
onchange="getVal(this.options[this.selectedIndex].value,'myvalue');"/>
Java腳本
function getVal(myvalue){
//do your stuff
document.getElementById("book_select").value="-1";
}
我還建議不要將選定的值存儲在隱藏字段中,而必須在某個div中顯示它們,否則用戶可能會感到困惑,並繼續一次又一次地選擇相同的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.