表单提交方式

表单提交方式
            * 使用submit提交
                    <form>
                            .....
                           <input type="submit" />
                    </form>

            * 使用button提交表单
                     - 代码
                       //实现提交方法
                        function form1() {
                              //获取form
                              var form1 = document.getElementById("form1");
                              //设置action
                              form1.action = "hello.html";
                              //提交form表单
                              form1.submit();
                         }

            * 使用超链接提交
                        - 代码
                         <a href="hello.html?username=123456">使用超链接提交</a>

            * onclick:鼠标点击事件
               onchange:改变内容(一般和select一起使用)

               onfocus:得到焦点 (ie5、某些版本的ie6)
               onblur:失去焦点

<body>
    <form id="form1" >
        <input type="text" name="username"/>
        <br/>
        <input type="button" value="提交" onclick="form1();"/>
    </form>

    <hr/>

    <a href="hello.html?username=123456">使用超链接提交</a>

    <hr/>
    <input type="text" id="id1" name="text1" value="please input" onfocus="focus1();" onblur="blur1();"/>
 </body>
 
 <script type="text/javascript">
    //得到焦点
    function focus1() {
        //alert("foucus.");
        var input1 = document.getElementById("id1");
        input1.value = "";
    }

    //失去焦点
    function blur1() {
        //alert("blur.");
        var input1 = document.getElementById("id1");
        input1.value = "please input";
    }

    //实现提交方法
    function form1() {
        //获取form
        var form1 = document.getElementById("form1");
        //设置action
        form1.action = "hello.html";
        //提交form表单
        form1.submit();
    }
        
 </script>
原文地址:https://www.cnblogs.com/sunli0205/p/6026715.html