选中单选按钮组后,对应文本框才可用,效果如图:
代码:
<html xmlns=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <style> input{border:1px solid #cccccc; background-color:expression((this.readOnly && this.readOnly==true)?"#f0f0f0":"")} </style> <SCRIPT Language="JavaScript">
function SetEnable() { if (document.getElementById("rd1").checked) { document.getElementById("txt1").readOnly = false; document.getElementById("txt2").readOnly = true; document.form1.txt1.focus(); } else { document.getElementById("txt1").readOnly = true; document.getElementById("txt2").readOnly = false; document.form1.txt2.focus(); } } </SCRIPT> </head> <body> <form id="form1" name="form1" method="post" action=""> <p> <label> <input type="radio" name="RadioGroup1" id="rd1" value="rd1" onclick="SetEnable()" /> 单选</label> <input type="text" id="txt1" name="textfield" /> <br /> <label> <input type="radio" name="RadioGroup1" id="rd2" value="rd2" onclick="SetEnable()" /> 单选</label> <input type="text" id="txt2" name="textfield2" /> <br /> </p> </form> </body> </html>
|
注:"border:1px solid #cccccc;"用来设置文本框的样式.
阅读(1308) | 评论(0) | 转发(0) |