<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地址
原文:https://www.cnblogs.com/HByang/p/12780822.html