Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1101274
  • 博文数量: 60
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 2500
  • 用 户 组: 普通用户
  • 注册时间: 2006-12-19 19:47
文章分类

全部博文(60)

文章存档

2009年(6)

2008年(54)

我的朋友

分类: 系统运维

2008-04-19 19:45:13

 
选中单选按钮组后,对应文本框才可用,效果如图:
代码:
 

<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;"用来设置文本框的样式.

阅读(1274) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~