how can I deselect struts2 select list from javascripts?
eg.
<s:select name="bookIds" list="bookList" listKey="key"
listValue="value" multiple="true" theme="simple"
onchange="getVal(this.options[this.selectedIndex].value,'myvalue');"/>
I want to deselect all the list after onchange event.
Declare headerKey
and 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');"/>
Javascript
function getVal(myvalue){
//do your stuff
document.getElementById("book_select").value="-1";
}
I also suggest that instead of storing the selected values in a hidden field you must show them in some div, otherwise users may get confuse and keep on selecting the same values again and again.
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.