select checkbox 控制input
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function SetReadOnly(){
if (document.all.testselect.value == 0){
document.all.testinput.disabled = true;
document.all.testinput.readOnly = true;
document.all.testinput.value = 0;
}
else{
document.all.testinput.disabled = false;
document.all.testinput.readOnly = false;
}
}
function SetReadOnly2(){
if (document.all.checkbox1.checked)
{
document.all.testinput.disabled = false;
document.all.testinput.readOnly = false;
document.all.testinput.value = 1;
}
else
{
document.all.testinput.disabled = true;
document.all.testinput.readOnly = true;
document.all.testinput.value = 0;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="SetReadOnly()">
<!--<select id="testselect" onchange="SetReadOnly()">
<option value="0">非表示</option>
<option value="1">表示</option>
</select> -->
<input id="testinput" type="text" value="a">
<input type='checkbox' name='checkbox1' id='checkbox1' value='7' onclick="SetReadOnly2()">
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function SetReadOnly(){
if (document.all.testselect.value == 0){
document.all.testinput.disabled = true;
document.all.testinput.readOnly = true;
document.all.testinput.value = 0;
}
else{
document.all.testinput.disabled = false;
document.all.testinput.readOnly = false;
}
}
function SetReadOnly2(){
if (document.all.checkbox1.checked)
{
document.all.testinput.disabled = false;
document.all.testinput.readOnly = false;
document.all.testinput.value = 1;
}
else
{
document.all.testinput.disabled = true;
document.all.testinput.readOnly = true;
document.all.testinput.value = 0;
}
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="SetReadOnly()">
<!--<select id="testselect" onchange="SetReadOnly()">
<option value="0">非表示</option>
<option value="1">表示</option>
</select> -->
<input id="testinput" type="text" value="a">
<input type='checkbox' name='checkbox1' id='checkbox1' value='7' onclick="SetReadOnly2()">
</BODY>
</HTML>