[英]Struts2 select tag add/remove values using javascript
我想使用struts2中的javascript從列表框中添加/刪除值。 我該怎么辦?
<s:select label="Select Month"
name="monthname"
headerKey="1"
headerValue="-- Please Select --"
list="#{'01':'January','02':'February','03':'March','04':'April',
'05':'May','06':'June','07':'July','08':'August','09':'September','10':
'October','11':'November','12':'December'}"
/>
假設我想從列表中刪除1月或通過struts2中的javascript在列表中添加新月。 我將如何實施?
提前致謝。
Struts2與它無關。
我建議您看一下jQuery,因為它很簡單:
<select>
<option>Jan
<option>Feb
<option>Mar
<option>Apr
<option>Jun
</select>
<input type="button" id="removeJanuary" value="Remove January">
<script>
$(function() {
$('#removeJanuary').click(function() {
$("option:contains('Jan')").remove();
});
});
</script>
參見示例: http : //jsbin.com/ajoqa
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.