zoukankan      html  css  js  c++  java
  • javascript获取表单值的7种方式

    见代码:

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>表单对象--获取表单值的7种方式</title>
    </head>
    <body>
        <form action="" name="myform">
            <input type="text" name="user" value="admin">
        </form>
    
        <script>
            document.write(document.myform.user.value+"1<br/>");
            document.write(document['myform'].user.value+"2<br/>");
            document.write(document.forms.myform.user.value+"3<br/>");
            document.write(document.forms[0].user.value+"5<br/>");
            document.write(document.forms['myform'].user.value+"4<br/>");
            document.write(document.forms.item(0).user.value+"6<br/>");
            document.write(document.forms.item('myform').user.value+"7<br/>");//FF可能不支持
            
        </script>
    </body>
    </html>

    推荐使用

    document.write(document.myform.user.value);

  • 相关阅读:
    FFmpeg RTSP流通过UDP传输问题
    Hibernate
    定时刷新和跳转和停止
    md5
    xxx.class类型类
    android开发-java
    爬虫scrapy
    lettuce之springboot整合redis
    Netty
    java线程池
  • 原文地址:https://www.cnblogs.com/52fhy/p/3969824.html
Copyright © 2011-2022 走看看