为什么这段代码有错误

时间:2011-05-11 10:05:38

标签: javascript html

//this is a part of html code
<form>
    <b>user:</b> <input type="text" name="user" size="25"/>
    <input type="button" name ="submit" value="confirm" onclick= "mehdi(this.form)"/>
</form>
<script type="text/javascript">
    function mehdi(rno){
        rno.user.value =  2 * Math.PI ;//this is error line user is unknown 

        alert(rno);
        return rno;
    }
</script>

我能做什么?

1 个答案:

答案 0 :(得分:0)

试试这个

<form>
    <b>user:</b> <input type="text" name="user" size="25"/>
 <input type="button" name ="submit" value="confirm" onclick= "mehdi(this.form)">
</form>

 <script type="text/javascript">
          function mehdi(rno)
          {
           rno.user.value =  2 * Math.PI ;//this is error line user is unknown 

           alert(rno.user.value);
           return rno.user.value;
           }

 </script>