<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>

解决方案 »

  1.   

    <input name="yinga" type="text" id="yinga" value="0" size="6" /> 
    这个文本输入框的id与函数重名了,把这个id改了或者函数名改了就可以了。
      

  2.   

    重名的问题,改成onclick="window.yinga();"即可 <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="window.yinga();"> <span class="STYLE2">口干咽燥 </span> 
    <input name="yinga" type="text" id="yinga" value="0" size="6" />
    </form> 
    </body> 
    </html>