Click here to Skip to main content
13,142,065 members (62,211 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 13 Jan 2005

Multiple Action Forms

, 13 Jan 2005
Rate this:
Please Sign up or sign in to vote.
How to send data from a form to multiple pages at once.


Have you ever wanted to make a simple form do multiple actions and you didn't know how. The answer was hidden from me for some time, but I managed to imagine how to do this when I read an article by Chris Maunder "Specifying multiple actions from a single Form".

In that article Chris manages to send information of the form to different pages, but there he needs different buttons for each action. So, I decided to edit a little bit of his code, to get multiple actions done by pressing the Submit button once. Now, I will explain you how to do this.

First let's have a simple form like this:

<form name=Form1 action= "login1.php" method=post>
Username <input type="text" name="username">
Password <input type="password" name="password">
<input type="submit" value="Send" name="button1" 

                     onclick="return OnButton1();">

Now, we have got a form. When we click the Submit button, it calls a JavaScript function:

<script language="javascript">
function OnButton1()
    document.Form1.action = "login2.php"    // First target = "iframe1";    // Open in a iframe
    document.Form1.submit();        // Submit the page
    document.Form1.action = "page3.php"    // Second target = "iframe2";    // Open in a iframe
    document.Form1.submit();        // Submit the page
    return true;

OK, now we are submitting the data to two pages. As you can see they have got a target like a frame. This is because we need it to open the two new pages with the data, but for not bothering the user we hide the IFRAMEs like this:

<div style="visibility:hidden">
<iframe NAME="iframe1" WIDTH="40" HEIGHT="40"></iframe>
<iframe NAME="iframe2" WIDTH="40" HEIGHT="40"></iframe>

The page will send the data to IFRAME and the information will be processed as you wanted.

Note: The user will only see login1.php confirmation and not the second login confirmation. Maybe you could create a page for the user to know if he could login in both pages or like me create a page that redirects to the index.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Uron Tuman
Web Developer
Chile Chile
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionWorks Great! Pin
Member 979572929-Jan-13 10:15
memberMember 979572929-Jan-13 10:15 
This script does basically everything I have wanted! It not only submits to both locations like I needed to. But, it even remains on the same page (or at least appears to)

I was wondering if there would be a way to maybe add a info bar across the top of the re-loaded page or some type of indication that the form was submitted successfully? Right now when you complete the form it just looks like it goes no where in all actuality it is working.

I am really hoping you are willing to help me out on this. I really do appreciate you opening your code up for the world. Thank you!
QuestionSecond action not working Pin
Edwin Herrendorfer22-Feb-12 2:37
memberEdwin Herrendorfer22-Feb-12 2:37 
Questionmultiple action form submit Pin
robert McCorkle5-Apr-07 23:07
memberrobert McCorkle5-Apr-07 23:07 
Questioncan you help me! [modified] Pin
Nguyen Ba Luu13-Aug-06 22:49
memberNguyen Ba Luu13-Aug-06 22:49 
Generaldoesnt work Pin
MACscr16-Apr-06 23:18
memberMACscr16-Apr-06 23:18 
GeneralRe: doesnt work Pin
Benyi Robert17-Nov-11 4:47
memberBenyi Robert17-Nov-11 4:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170915.1 | Last Updated 13 Jan 2005
Article Copyright 2005 by Uron Tuman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid