0

我想在 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'}"
/>

假设我想从列表中删除一月或通过 struts2 中的 javascript 在列表中添加新月份。我将如何实施它?

提前致谢。

4

1 回答 1

1

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

于 2009-04-17T13:48:10.750 回答