📄 10.6 复选框和文本框的联动效果.htm
字号:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>标题页</title>
<script language="javascript">
function chk(obj,txtIndex)
{
var tmpInput = document.getElementsByName("textfield")[txtIndex]; //获取指定的文本框
obj.checked?tmpInput.disabled=false:tmpInput.disabled=true; //判断文本框是否处于选中状态
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<input name="che" type="checkbox" value="" onclick="chk(this,'0')"/>
<input type="text" name="textfield" disabled=true /><BR/>
<input name="che" type="checkbox" value="" onclick="chk(this,'1')"/>
<input type="text" name="textfield" disabled=true /><BR/>
<input name="che" type="checkbox" value="" onclick="chk(this,'2')"/>
<input type="text" name="textfield" disabled=true /><BR/>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -