首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

<html:radio>/<html:select> 默许选中

2012-10-21 
html:radio/html:select 默认选中html:radiotrtd width30% value1咨询/html:radiohtml

<html:radio>/<html:select> 默认选中
<html:radio>

<tr><td width="30%" value="1">咨询</html:radio>&nbsp;&nbsp;&nbsp;&nbsp;<html:radio property="sendType" value="2" >办件</html:radio>&nbsp;&nbsp;&nbsp;&nbsp;<html:radio property="sendType" value="3">联办</html:radio></td></tr>


<html:select>

   <tr>             <td width="30%" styleonfocus="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 value="0" >是</html:radio><html:radio property="caseBean.configFee" value="1" >否</html:radio></td><td maxlength="15"styleonfocus="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 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 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>

热点排行