简体   繁体   中英

why this code has error

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

what can i do?

Try This

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM