[英]Struts2 select tag add/remove values using javascript
I wanted to add/remove values from the list box using javascript in struts2. 我想使用struts2中的javascript从列表框中添加/删除值。 How could I do that?
我该怎么办?
<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'}"
/>
Let's say I wanted to remove January from the list or add new month in list by javascript in struts2. 假设我想从列表中删除1月或通过struts2中的javascript在列表中添加新月。 how do I will implement it?
我将如何实施?
Thanks in advance. 提前致谢。
Struts2 has nothing to do with it. Struts2与它无关。
I recommend you look at jQuery, because it makes this trivial: 我建议您看一下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>
See example: http://jsbin.com/ajoqa 参见示例: http : //jsbin.com/ajoqa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.