刚开始用struts2+jquery做页面,有些控件的用法在这里做个记录:
1.combobox(selectbox):
2.radiobox:
1.combobox(selectbox):
<div class="elementDiv">
<div class="left_td"><label>オペレータ種別名(<font color="red">*</font>) : </label></div>
<!-- 最初に空白のエリアが必要の場合は、下記のプロパティを使う:headerKey="-1" headerValue="――" -->
<!-- 这里opeGrpMap是action中定义的List<HaspMap>,其key是groupId,value是groupName -->
<div class="right_td">
<s:select id="opeGrpCombo" name="opeGrpCombo" list="opeGrpMap" Style="width:200px;"></s:select>
</div>
</div>
// js设置combobox的值 $("#opeGrpCombo").val(0); // or $("#opeGrpCombo").get(0).selectedIndex = 0; // 获取当前选中的value $("#opeGrpCombo option:selected").val(); // 获取当前选中的text $("#opeGrpCombo option:selected").text();
2.radiobox:
<div class="elementDiv">
<div class="left_td" style="margin-top:6px;"><label>パスワード初期化 : </label></div>
<div class="right_td">
<s:radio id="pwdRstRadio" name="pwdRstRadio" list="#{'1':'初期化する','0':'初期化しない'}" value="0"></s:radio>
</div>
</div>
// js设置radiobox的选中值(pwdRstRadio0是struts2自动生成的id,另一个是pwdRstRadio1) $("#pwdRstRadio0").attr("checked", true); // 获取radiobox当前选中的value $("input[name='pwdRstRadio']:checked").val()