The ability to implement data for multiple Web pages to receive the same form

Source: Internet
Author: User
Tags define case statement copy implement switch case
web| Data | Page Sometimes we encounter such a problem, that is, multiple pages to receive the same form of data, then how to achieve this function, this article will be elaborated.

We know that a form can be easily submitted to a processing page, just a submit button, but sometimes we have to use a different processing page to receive the form's data and deal with it. If we design separate forms for different processing pages, if the data collected is the same, in this case, it wastes both the page space and the time and effort when the large amount of data is entered. To solve this problem we only need to implement a table one-way multiple pages to submit data this function can be.

So how does this function? Here are three ways to do this:

  method One: use multiple button buttons, design a subroutine for each button's OnClick event, and read the value of the button to determine who submitted the data, the source code is as follows:

<script language= "JavaScript" > Function tosubmit1 () {document.submitform1.action = "1.asp"; Document.submitform1.submit (); function Tosubmit2 () {document.submitform1.action= "2.asp"; Document.submitform1.submit (); function Tosubmit3 () {document.submitform1.action= "3.asp"; Document.submitform1.submit (); } </script> </pead> <form name= "Submitform1" action= "method=" post "target=" _blank "> <input Type= "button" Name= "Submit1" value= "submitted to 1.asp" > <input type= "button" Name= "Submit2" value= "Submit to 2.asp" >< Input type= "button" Name= "Submit3" value= "Submit to 3.asp" > </form>
run code copy code Collection page

Square Law two: use multiple button buttons, define the processing of each button's OnClick event, do not need to determine the value of the button, and directly define the form's action value, the code is relatively simple, as follows:

<form name= "Submitform2" action= "method=" post "target=" _blank "><input name=" Submit1 "value=" submitted to 1.asp " Type= "button" ><input name= "Submit2" value= "submitted to 1.asp" type= "button" ><input name= "submit3" value= " Submit to 1.asp "type= button" ></form>
Run code Copy Code Save Code Collect this page

  method Three: the same use of multiple button buttons, but also for each button to design an onclick event subroutine, the difference is to use the switch case statement to determine the value of button buttons, so that the corresponding processing, the code is as follows:

<textarea id="code2"><form name= "submitform3" action= "method=" post "target=" _blank "><input type=" Submit "Name=" Submit1 " Value= "submitted to 1.asp" ><input type= "Submit" Name= "Submit2" value= "submitted to 2.asp" ><input type= "Submit" Name= " Submit3 "Value=" submitted to 3.asp "></form><script language=" javascript > function dothis (obj) {switch (Obj.va Lue) {case "submitted to 1.asp": document.submitform3.action= "1.asp"; Break Case "submitted to 2.asp": document.submitform3.action= "2.asp"; Break Case "submitted to 3.asp": document.submitform3.action= "3.asp"; Break }}</script></textarea>
Run code Copy Code Save Code Collect this page

In fact, the three methods cited in this article are similar, but in the treatment of a slightly different means, welcome to discuss.



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.