簡體   English   中英

取消選擇struts2從javascript中選擇

[英]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');"/>

我想在onc​​hange事件之后取消選擇所有列表。

聲明headerKeyheaderValue

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

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