一個form表單有兩個按鈕,分別提交到不同的頁面


<form action="" name="submitted" method="post">
    <input type="text" name="test"/>
    <button οnclick="test1()"/>測試1</button>
    <button οnclick="test2()"/>測試2</button>
</form>
</body>
</html>
 
<script>
    function test1(){
//        document.("表單的name值").action
//        document.("表單的name值").submit
        document.submitted.action="xxxxxxxxxxx";
        document.submitted.submit();
    }
    function test2() {
        document.submitted.action = "xxxxxxxxxxx";
        document.submitted.submit();
    }
</script>
xxxxxxxxxxx就是你要提交到哪url地址


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM