<html:radio>
<tr> <td width="30%" class="td1"> 发号类型: </td> <td> <html:radio property="sendType" value="1">咨询</html:radio> <html:radio property="sendType" value="2" >办件</html:radio> <html:radio property="sendType" value="3">联办</html:radio> </td> </tr>
<html:select>
<tr>
<td width="30%" class="td1">发号类型:</td>
<td>
<html:select property="sendType" styleClass="input" onfocus="style.backgroundColor='#e0f4ff'" onblur="style.backgroundColor='#fff'">
<html:option value="办件">办件</html:option>
<html:option value="咨询">咨询</html:option>
<html:option value="联办">联办</html:option>
</html:select>
</td>
</tr>当我们理解Struts ActionForm机制,我们就很清楚知道如何赋值到达我们的效果!
在Action跳转的时候设置ActionForm的对应属性值即可:
public ActionForward getSendNo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
....
SendNoForm send = (SendNoForm) form;
send.setSendType("2");
......
return mapping.findForward("sendNo");
}js获取页面的radio值
var temp ='';
var free = document.getElementsByName("caseBean.configFee")
for(var i = 0;i<free.length;i++){
if(free[i].checked)
temp = free[i].value;
}页面处理
<tr > <td class="td1"> <div align="right">是否收费: </div></td> <td align="left"> <html:radio property="caseBean.configFee" value="0" >是</html:radio> <html:radio property="caseBean.configFee" value="1" >否</html:radio> </td> <td class="td1"> <div align="right">免费缘由: </div></td> <td > <html:text property="caseBean.freeReason" maxlength="15"styleClass="input" onfocus="style.backgroundColor='#e0f4ff'" onblur="style.backgroundColor='#fff'"/> </td> </tr>
js获取check值
if(document.getElementById("caseBean.caseSMSFlag").checked)
{
document.getElementById("caseBean.caseSMSFlag").value='是';
if(document.getElementById("caseBean.caseMobile").value==""){
alert("告知号码不能为空");
document.getElementById("caseBean.caseMobile").focus();
return false;
} 页面处理
<html:checkbox property="caseBean.caseSMSFlag" value="是"/>
获取select值并强制赋值,当选择不予采用,采用类型不可编辑并给予默认值:
js:
function test(){
var ifAdopt = document.getElementById("ifAdopt").value;
if(ifAdopt == 3){
document.getElementById('adoptType').selectedIndex = 0;
document.getElementById("adoptType").disabled="true";
}else{
document.getElementById("adoptType").disabled="";
}
}jsp:
<td class="td1" width="20%"> <div align="right"><span style="color: red;">*</span>采纳类型</div> </td> <td width="15%"> <html:select property="ifAdopt" styleId="ifAdoptID" onchange="aaa();"> <html:option value="">--请选择--</html:option> <html:option value="1">采用</html:option> <html:option value="2">部分采用</html:option> <html:option value="3">不予采用</html:option> </html:select> </td> <td class="td1" width="20%"> <div align="right"><span style="color: red;">*</span>采用类型:</div> </td> <td width="15%"> <html:select property="adoptType" styleId="adoptType"> <html:option value="-1">--请选择--</html:option> <html:option value="1">媒体采用</html:option> <html:option value="2">信息摘编</html:option> <html:option value="9">其它</html:option> </html:select> </td>