日期:2014-05-18  浏览次数:20608 次

通过javascript改变文本框的值
<input type="text" id="res" name="result" size="20">
<script language=javascript>
document.getElementById("res").value=55;
</script>
为什么文本框中的值不会改变?求解答。。。。。

------解决方案--------------------
<html>
<title>XXXTest</title>
<head>
<script>
function onlo(){
document.getElementById("test").value=55;
}
</script>
</head>
<body onload="onlo()">
<input id="test" >
</body>
</html>

只有触发函数才会显示

------解决方案--------------------
HTML code

<html>
<body>
  <form action="">
    
      <input type="button" name="test"  id="test"  onclick ="doadd()">
    </form>

 
    </body>
    
    <script type="text/javascript">
    
    function doadd(){
    
     document.getElementById("test").value="";
    }
     
    </script>
</html>