Use js to submit a form to solve the problem that a page has multiple submit buttons. js form
Using js to submit a form solves the problem of multiple submit buttons on a page, mainly to determine whether the text is submitted and then execute the corresponding action, which is relatively simple.
<Pre class = "javascript" name = "code"> function check (txt) {$ j ("form "). submit (function () {if ($ txt = "submit") {this. action = "doAddMessage. action? Button = submit "; this. submit ();} else {this. action =" doAddMessage. action? Button = save "; this. submit ();}});} </pre> <br> <input type = "IMAGE" src = "style/blue/images/button/send.png" name = "button" value = "Submit" onclick =" check (this) "/> <input type =" IMAGE "src =" style/blue/images/button/saveToDraftBox.png "name =" button "value =" save "onclick =" check (this) "/> <pre> </pre> <p> <br> for example, two image buttons are submitted on the page. At this time, we can bind an onclick event to both of them, in this case, we use jquery's form to have an event called submit. </P> <p> because dwr is used in my project, I transfer the control of jquery to dwr, and jquery re-specifies a $ j. We get the form, then, use the submit event to determine the value of the value, so that you can jump to multiple pages. </P>
Multiple submission buttons in a form
Use JS to change the button submission page: <script type = "text/javascript">
Function fun () {document. myform. action = "path to be submitted ";}
</Script> <form name = "myform">
<Input type = "button" value = "Submit" onclick = "fun ()"/>
</Form>
How does one solve the problem of submitting two buttons to different pages in a form? Note: Two submissions are required (because both must change data in real time)
Write two different event buttons and pass different parameters. Then, the background accepts the judgment and goes to function selectOrder (){
Document. forms (0). action = "/path" document. forms (0). submit ();}