| Author |
A Form that can submit to two pages?
|
|
| Shaun 2004-08-18, 12:15 pm |
| Hi,
Is it possible to have a form that can be submitted to two different pages?
Obviously I can put two buttons on a form but how could the form action be
changed according to the button the user clicks? I am using PHP if this
helps!
Thanks
| |
| RResWeb 2004-08-18, 12:15 pm |
| I would use a javascript function called by a button click.
Here's the button
<input TYPE="button" VALUE="Submit " onClick="SendForm()">
Here's the javascript, given that the form name is "Comments":
function SendForm(){
document.Comments.action = Page1.php;
document.Comments.submit();
document.Comments.action = Page2.php;
document.Comments.submit();
}
Hope that's OK.
| |
| Michael Fesser 2004-08-18, 12:15 pm |
| .oO(Shaun)
>Is it possible to have a form that can be submitted to two different pages?
No (I don't consider Javascript an option on this, it's unreliable).
>Obviously I can put two buttons on a form but how could the form action be
>changed according to the button the user clicks?
You can't, but ...
>I am using PHP if this
>helps!
.... you can do whatever you want in the form-processing script on the
server. Send the data to a db, to an e-mail address, to another site ...
Micha
| |
| Gary White 2004-08-18, 7:15 pm |
| RResWeb wrote:
> function SendForm(){
> document.Comments.action = Page1.php;
> document.Comments.submit();
> document.Comments.action = Page2.php;
> document.Comments.submit();
> }
Of course that make the form unusable by anyone without JavaScript
enabled.
Gary
| |
| Gary White 2004-08-18, 7:15 pm |
| Shaun wrote:
>Is it possible to have a form that can be submitted to two different pages?
>Obviously I can put two buttons on a form but how could the form action be
>changed according to the button the user clicks? I am using PHP if this
>helps!
Not really. The best solution would be to have one script call the
other.
Gary
| |
|
| suggestion-
instead of using JavaScript as some method of having two submit buttons-
Instead, have a pair of radio buttons where the user decides what to do with
the submission.
on the processing page, check the value of the radio button.
if one value, execute one block of code. If other value, execute other block
of code.
that way, you only need one submit button, one processing page.
> Hi,
>
> Is it possible to have a form that can be submitted to two different pages?
> Obviously I can put two buttons on a form but how could the form action be
> changed according to the button the user clicks? I am using PHP if this
> helps!
>
> Thanks
>
>
|
|
|
|
| Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |