Using js to submit a form easily solves the problem of multiple button submissions on a page _ javascript skills

Source: Internet
Author: User
If you want to use js to submit a form, you will. If you want to implement a page with multiple submit buttons, will you? The following is a good example. The Code is as follows:


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 ();
}
});
}



 



For example, the page contains two image buttons for submission. At this time, we can bind them to The onclick event. At this time, we use the form of jquery to have an event called submit.


Because dwr is used in my project, I transfer the control of jquery to dwr, jquery re-specifies a $ j, we get the form, and then use the submit event, you can jump to multiple pages by judging the value.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.