繁体   English   中英

Struts2 Select标签使用javascript添加/删除值

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM