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

高手帮看一下这个单选框调用input为何出错?该如何处理

2012-04-09 
高手帮看一下这个单选框调用input为何出错?代码1:form nameAddUserForm methodpost actionpay.ph

高手帮看一下这个单选框调用input为何出错?
代码1:
<form name="AddUserForm" method="post" action="pay.php?t=2" id="form2"><table style="width:100%;" cellspacing="0" border="1">
  <tr>
  <td>我的收款方式:
<input type="radio" name="xtmod" value="bank" checked onClick="bank.style.visibility='visible';address.style.visibility='hidden'">银行/支付宝 
  <input type="radio" name="xtmod" value="address" onClick="bank.style.visibility='hidden';address.style.visibility='visible'">邮局 我的姓名:<input name="name" 

type="text" id="name" value="传月刚" maxlength="20" style="width: 55px" disabled /><input type="hidden" name="name" id="name" value="传月刚"></td>
  </tr>
  <tr>
  <td><div id='address' style='position:absolute; visibility: hidden'>帐号地址: 
  <input name="address" type="text" id="address" value="408403重庆市南川市水江镇" maxlength="100" style="width: 600px" disabled /><input type="hidden" 

name="address" id="address" value="408403重庆市南川市水江镇"> 
  </div>
  <div id='bank' style='visibility: visible'>帐号地址: 
  <input name="bank" type="text" id="bank" value="支付宝:4635634@qq.com" maxlength="100" style="width: 600px" disabled /><input type="hidden" name="bank" 

id="bank" value="支付宝:4635634@qq.com">
  </div>
 <tr>
</table></form>

需要使input不能输入,在input能输入的情况下这代码正确能正确运行:


代码2:
<form name="AddUserForm" method="post" action="pay.php?t=2" id="form2"><table style="width:100%;" cellspacing="0" border="1">
  <tr>
  <td>我的收款方式:
<input type="radio" name="xtmod" value="bank" checked onClick="bank.style.visibility='visible';address.style.visibility='hidden'">银行/支付宝 
  <input type="radio" name="xtmod" value="address" onClick="bank.style.visibility='hidden';address.style.visibility='visible'">邮局 我的姓名:<input name="name" 

type="text" id="name" value="传月刚" maxlength="20" style="width: 55px" disabled /><input type="hidden" name="name" id="name" value="传月刚"></td>
  </tr>
  <tr>
  <td><div id='address' style='position:absolute; visibility: hidden'>帐号地址: 
  <input name="address" type="text" id="address" value="408403重庆市南川市水江镇" maxlength="100" style="width: 600px" />
  </div>
  <div id='bank' style='visibility: visible'>帐号地址: 
  <input name="bank" type="text" id="bank" value="支付宝:4635634@qq.com" maxlength="100" style="width: 600px" />
  </div>
 <tr>
</table></form>

代码2能正确运行,谁能帮忙将代码1主,调试好?!谢谢!需要input在disabled状态下正确运行。


[解决办法]
<input type="radio" name="xtmod" value="bank" checked onClick="document.getElementById('bank').style.visibility='visible';document.getElementById('address').style.visibility='hidden'">银行/支付宝 


<input type="radio" name="xtmod" value="address" onClick="document.getElementById('bank').style.visibility='hidden';document.getElementById('address').style.visibility='visible'">邮局 我的姓名:<input name="name" 

[解决办法]

HTML code
<form name="AddUserForm" method="post" action="pay.php?t=2" id="form2"><table style="width:100%;" cellspacing="0" border="1">   <tr>   <td>我的收款方式: <input type="radio" name="xtmod" value="bank" checked onClick="Div2.style.visibility='visible';Div1.style.visibility='hidden'">银行/支付宝    <input type="radio" name="xtmod" value="address" onClick="Div2.style.visibility='hidden';Div1.style.visibility='visible'">邮局 我的姓名:<input name="name"  type="text" id="Text1" value="传月刚" maxlength="20" style="width: 55px" disabled /><input type="hidden" name="name" id="name" value="传月刚"></td>   </tr>   <tr>   <td><div id='Div1' style='position:absolute; visibility: hidden'>帐号地址:    <input name="address" type="text" id="address" value="408403重庆市南川市水江镇" maxlength="100" style="width: 600px" disabled /><input type="hidden"  name="address" id="address" value="408403重庆市南川市水江镇">    </div>   <div id='Div2' style='visibility: visible'>帐号地址:    <input name="bank" type="text" id="bank" value="支付宝:4635634@qq.com" maxlength="100" style="width: 600px" disabled /><input type="hidden" name="bank"  id="bank" value="支付宝:4635634@qq.com">   </div>  <tr></table></form> 

热点排行