FORMS - Multiple actions from a SUBMIT button |
FORMS - Multiple actions from a SUBMIT button |
Shminglebaart |
Oct 6 2006, 11:09 AM
Post
#1
|
Group: Members Posts: 2 Joined: 6-October 06 Member No.: 351 |
Say I had a form on a site and when the used clicked SUBMIT, I wanted to perform TWO actions, I want it to go off and populate a database AND i want it to email the results elsewhere.
Is it possible to set two actions from a submit button? |
Christian J |
Oct 6 2006, 11:27 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
|
linus |
Feb 14 2011, 04:32 PM
Post
#3
|
Group: Members Posts: 1 Joined: 14-February 11 Member No.: 13,869 |
CODE <html> <head> <script language="Javascript"> <!-- function OnButton1() { document.Form1.action = "response1.php" // document.Form1.target = "_blank"; // Open in a new window document.Form1.submit(); // Submit the page return true; } function OnButton2() { document.Form1.action = "response2.php" document.Form1.target = "_blank"; // Open in a new window document.Form1.submit(); // Submit the page return true; } --> </script> <noscript>You need Javascript enabled for this to work</noscript> </head> <body> <!-- create the form --> <form name="Form1" method="post"> <!-- Add the data entry bits --> Your Name <input type="text" name="name" size="10" /><br /> <!-- Add some buttons --> <INPUT type="button" value="Button1" name=name onclick="OnButton1(); OnButton2();"> <!-- close the form --> </form> </body> </html> i am working through the same issue... this form is working out for me so far. This post has been edited by linus: Feb 14 2011, 04:32 PM |
Darin McGrew |
Feb 14 2011, 10:30 PM
Post
#4
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
QUOTE i am working through the same issue... this form is working out for me so far. It won't work when JavaScript is disabled/unavailable. |
Virendrasinh Gohil |
Apr 12 2011, 08:28 AM
Post
#5
|
Group: Members Posts: 1 Joined: 12-April 11 Member No.: 14,320 |
CODE function OnButton1() document.Form1.action = "response1.php" document.Form1.submit(); // Submit the page function OnButton2() document.Form1.action = "response2.php" document.Form1.submit(); // Submit the page <form name="Form1" method="post"> <INPUT type="button" value="Button1" name=name onclick="OnButton1(); OnButton2();"> How do I pass any extra information as parameter based on which function called? |
rodrigosieja |
Nov 19 2013, 01:23 PM
Post
#6
|
Group: Members Posts: 1 Joined: 19-November 13 Member No.: 20,009 |
CODE function OnButton1() { document.Form1.action = "response1.php" document.Form1.submit(); // Submit the page } function OnButton2() { document.Form1.action = "response2.php" document.Form1.submit(); // Submit the page } <form name="Form1" method="post"> <input type="button" value="Button1" name="name" onclick="OnButton1(); OnButton2();"> How do I pass any extra information as parameter based on which function called? Maybe through GET method? Example: CODE function OnButton1() { document.Form1.action = "response1.php?param=test" document.Form1.submit(); // Submit the page } And within response1.php: CODE $param = $_GET['param']; if($param == 'test') { echo 'Test passed<br /><br />'; } else { echo 'Test failed<br /><br />'; } This post has been edited by rodrigosieja: Nov 19 2013, 01:26 PM |
Lo-Fi Version | Time is now: 18th April 2024 - 11:35 PM |