table中动态显示隐藏行,且在多种浏览器中支持

 效果,如下图:



 

html代码如下:

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<br>

<div align="center">
<br>
<br>
<br>
<br>
<br>

<table border="0" cellpadding="0" cellspacing="0" class="centertable">
 <tr>
  <td>
  <table border='0' cellspacing='0' cellpadding='0' width="">
   <tr>
    <td width='729' height="413" valign='top' class='content' align="left">
    <div id="loginborder">
    <form  action="<foundation:root/>j_security_check.check" method="post">
     <input type="hidden" name="_eosFlowAction" value="login">
     <table align="center" border="0" width="100%">
      <tr><td colspan="3" style="text-align:left"><label><input type="radio" name="radio" id="pecard_password" value="pecard_password" checked="checked" οnclick="on_pecardpassword()"/><font size=2>平台密码</font></label>&nbsp;&nbsp;&nbsp;&nbsp;<label><input type="radio" name="radio" id="messagecode" value="messagecode" οnclick="on_messagecode()"/><font size=2>短信密码</font></label><p></td></tr>
      <tr>
       <td>用户名:</td>
       <td colspan="2"><input type="text" id="j_username" name="j_username"></td>
       <td><font style="color:red">
       &nbsp;</font></td>
      </tr>
      
      <tbody id="pecardpassword_tbody">
      <tr>
       <td>密 码:</td>
       <td colspan="2"><input type="password" id="j_password" name="j_password"></td>
       <td><font id="mypassword" style="color:red">
       &nbsp;</font></td>
      </tr>
      </tbody>
      
      <tbody id="messagecode_tbody" style="display:none;">
      <tr>
       <td style="width:50px">密 码:</td>
       <td style="width:80px"><input type="password" id="j_password_messagecode" name="j_password_messagecode"></td>
       <td style="width:80px;text-align:left;"><a href="#" οnclick="messageCode()"><font size="2" color="green">短信密码</font></a></td>
       <td><font id="mypassword" style="color:red">
       &nbsp;</font></td>
      </tr>
      </tbody>
      
      <tr>
       <td style="width:50px">验证码:</td>
       <td style="width:80px"><input type="text" id="j_captcha_response" name="j_captcha_response"></td>
       <td style="width:80px;text-align:left;"><img src="<foundation:root/>captchaImageServlet" width="80" height="25"  οnclick="javascript:this.src=sys.basePath+'captchaImageServlet?e='+new Date()" /></td>
       <td><font id="myimg" style="color:red">
       &nbsp;</font></td>
      </tr>
      
      <tr>
       <td>&nbsp;</td>
          <td align="left" >
            <input type="button" value="登 录" οnclick="javascript:onlogin2();">
          </td>
          <td colspan="2" align="left">
           <a href="#" onClick="javascript:lossPwd();">忘记密码?</a>
          </td>
      </tr>
      
      <tr>
       <td colspan="2"><input type="hidden" id="loginType" name="loginType" value=""></td>
      </tr>
     </table>
    </form>
    </div>
    </td>
   </tr>
  </table>
  </td>
 </tr>
</table>
</div>
<script type="text/javascript">
 //平台密码页面显示
 function on_pecardpassword(){
  document.getElementById('pecardpassword_tbody').style.display="";//显示
  document.getElementById('messagecode_tbody').style.display='none'//隐藏
  password = new Ext.form.TextField({applyTo:'j_password',width:160,inputType: 'password',allowBlank:true});
 }
 
 //短信密码页面显示
 function on_messagecode(){
  document.getElementById('messagecode_tbody').style.display="";//显示
  document.getElementById('pecardpassword_tbody').style.display='none'//隐藏
  password = new Ext.form.TextField({applyTo:'j_password_messagecode',width:80,inputType: 'password',allowBlank:true});
 }
</script>
</body>
注意:tbody显示用style="",能得到多种浏览器支持,而不是用style="display:block;",如果用了它之后,能在IE中正常显示,如果在火狐、google浏览器中显示错乱。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值