<html>
<script language="javascript">
function yinga(){
document.form1.yinga.value=5;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="a.asp">
<input name="ying1" type="checkbox" id="ying1" value="3" onclick="yinga();"><span class="STYLE2">口干咽燥</span>
<input name="yinga" type="text" id="yinga" value="0" size="6" />
</form>
</body>
</html>
为什么上面的有错误,下面却是可以的:
<html>
<script language="javascript">
function yinga(){
document.form1.yinga.value=5;
}
</script>
<body><input name="ying1" type="checkbox" id="ying1" value="3" onclick="yinga();">
<form id="form1" name="form1" method="post" action="a.asp">
<span class="STYLE2">口干咽燥</span>
<input name="yinga" type="text" id="yinga" value="0" size="6" />
</form>
</body>
</html>
<script language="javascript">
function yinga(){
document.form1.yinga.value=5;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="a.asp">
<input name="ying1" type="checkbox" id="ying1" value="3" onclick="yinga();"><span class="STYLE2">口干咽燥</span>
<input name="yinga" type="text" id="yinga" value="0" size="6" />
</form>
</body>
</html>
为什么上面的有错误,下面却是可以的:
<html>
<script language="javascript">
function yinga(){
document.form1.yinga.value=5;
}
</script>
<body><input name="ying1" type="checkbox" id="ying1" value="3" onclick="yinga();">
<form id="form1" name="form1" method="post" action="a.asp">
<span class="STYLE2">口干咽燥</span>
<input name="yinga" type="text" id="yinga" value="0" size="6" />
</form>
</body>
</html>
这个文本输入框的id与函数重名了,把这个id改了或者函数名改了就可以了。
<script language="javascript">
function yinga(){
document.form1.yinga.value = 5;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="a.asp">
<input name="ying1" type="checkbox" id="ying1" value="3" onclick="window.yinga();"> <span class="STYLE2">口干咽燥 </span>
<input name="yinga" type="text" id="yinga" value="0" size="6" />
</form>
</body>
</html>