js表单提交

<!DOCTYPE html>


<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
        onload = function () {
            var form = document.getElementById('form');
            form.onsubmit = function () {
                alert('hhhh');
            };
            document.getElementById('btnSimul').onclick = function () {
                //form.submit();//第一种提交方式,不触发onsubmit事件
                document.getElementById('btnSubmit').click();//第二种提交方式,触发onsubmit事件

            };


            




        }
    </script>
</head>
<body>
    <form method="post" action="hello.html" id="form">
        <input type="button" name="name" value="模拟提交 " id="btnSimul"/>
        <input type="text" name="name" value=" " />
        <input type="submit" name="name" value=" 提交" id="btnSubmit" />
    </form>


</body>
</html>
posted @ 2018-05-10 16:50  dxm809  阅读(97)  评论(0)    收藏  举报