在页面上通过JavaScript控制表格的隐藏和显示

来源:互联网 发布:淘宝可以买保健品吗 编辑:程序博客网 时间:2024/04/29 21:53

 

JavaScript的控制语句

   function selectInjunction() {
    if(document.getElementById("injunctionType").value.trim() == 0) {
     document.all.displaysubcode.style.display = "none";
     document.all.displayinjunction.style.display = "";
    
     document.all.pipeizhengze.style.display = "";
    } else if(document.getElementById("injunctionType").value.trim() == 3) {
     document.all.displaysubcode.style.display = "";
     document.all.displayinjunction.style.display = "none";
    
     document.all.pipeizhengze.style.display = "";
     
    } else if(document.getElementById("injunctionType").value.trim() == 4) {
     document.all.displaysubcode.style.display = "";
     document.all.displayinjunction.style.display = "";
    
     document.all.pipeizhengze.style.display = "none";
    } else if(document.getElementById("injunctionType").value.trim() == 7) {
     document.all.displaysubcode.style.display = "none";
     document.all.displayinjunction.style.display = "none";
     document.all.pipeizhengze.style.display = "none";
    }
   }

 

页面上的触发事件

  <td width=45% align="right"><bean:message bundle="ALL_RESOURCE_KEY" key="servinceInjunction.intype.edit"/></td>
     <td width="55%" align="left">
      <html:select name="smsServiceInjunctionForm" property="injunctionType" onchange="selectInjunction()">
       <html:option value="-1"><bean:message bundle="ALL_RESOURCE_KEY" key="servinceInjunction.pselect.edit"/></html:option>
       <html:option value="0"><bean:message bundle="ALL_RESOURCE_KEY" key="smsServinceInjunction.injunction"/></html:option>
       <html:option value="3"><bean:message bundle="ALL_RESOURCE_KEY" key="smsServinceInjunction.subcode"/></html:option>
       <html:option value="4"><bean:message bundle="ALL_RESOURCE_KEY" key="smsServinceInjunction.subcodeinjunction"/></html:option>
       <html:option value="7">默认路由</html:option>
      </html:select><font color="#FF0000"><html:errors property="defaulterror"/><bean:message bundle="ALL_RESOURCE_KEY" key="global.bitian"/></font>
      </td>
    </tr>

 

页面的表格

<table><tr>
      <td>
       <html:radio name="smsServiceInjunctionForm" property="injunctionMode" value="0"><bean:message bundle="ALL_RESOURCE_KEY" key="servinceInjunction.mode0.edit"/></html:radio>
       <html:radio name="smsServiceInjunctionForm" property="injunctionMode" value="1"><bean:message bundle="ALL_RESOURCE_KEY" key="servinceInjunction.mode1.edit"/></html:radio>
      </td>
      <td id="pipeizhengze" style="display:none">
       <html:radio name="smsServiceInjunctionForm" property="injunctionMode" value="2">正则匹配</html:radio>
      </td>
      <td>
       <font color="#FF0000"><bean:message bundle="ALL_RESOURCE_KEY" key="global.bitian"/></font>
      </td>
      </tr></table>