为什么此代码有错误

why this code has error

本文关键字:有错误 代码 为什么      更新时间:2023-09-26
//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>

我能做什么?

试试这个

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