Connecting Tech Pros Worldwide Forums | Help | Site Map

How to make scripts for 2 submit buttons?

Penny
Guest
 
Posts: n/a
#1: Jul 23 '05
Hi all,

I have a checkout page in my online shopping cart that needs two submit
buttons that direct to two seperate pages. Whichever button the user clicks,
the destination page will use much the same values via Request.Form but will
just do different things with them.

One of the buttons will be a submit button. Can I have two submit buttons or
even another button in the same form that redirects to a different page than
the submit button redirects to but also allows the target page to use
Request.Form to return the previous pages form values?

Is there a javascript to do this?

Sorry its so long winded.

Regards

Penny.



Randy Webb
Guest
 
Posts: n/a
#2: Jul 23 '05

re: How to make scripts for 2 submit buttons?


Penny wrote:[color=blue]
> Hi all,
>
> I have a checkout page in my online shopping cart that needs two submit
> buttons that direct to two seperate pages. Whichever button the user clicks,
> the destination page will use much the same values via Request.Form but will
> just do different things with them.
>
> One of the buttons will be a submit button. Can I have two submit buttons or
> even another button in the same form that redirects to a different page than
> the submit button redirects to but also allows the target page to use
> Request.Form to return the previous pages form values?[/color]

It is better to let the server determine what to do with the page, in
case JS is disabled.
[color=blue]
> Is there a javascript to do this?[/color]

<input type="submit" onclick="this.form.action='somePage.php'"
value="somePage">

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Penny
Guest
 
Posts: n/a
#3: Jul 23 '05

re: How to make scripts for 2 submit buttons?


Hi Randy,
[color=blue]
> It is better to let the server determine what to do with the page, in
> case JS is disabled.[/color]

By this do you mean use ASP/PHP or the like to determine which page to
redirect to?
[color=blue]
><input type="submit" onclick="this.form.action='somePage.php'"[/color]
value="somePage">

Do you mean that you can have 2 submit buttons of the type "submit" and use
each one's onclick to redirect accordingly?

Regards

Penny



David Dorward
Guest
 
Posts: n/a
#4: Jul 23 '05

re: How to make scripts for 2 submit buttons?


Penny wrote:
[color=blue][color=green]
>> It is better to let the server determine what to do with the page, in
>> case JS is disabled.[/color][/color]
[color=blue]
> By this do you mean use ASP/PHP or the like to determine which page to
> redirect to?[/color]

Or whatever language you are using on the server.

if ($_REQUEST['submit'] == "itemOne") {
itemOne();
} elsif ($_REQUEST['submit'] == "itemTwo") {
itemTwo();
} else {
defaultBehaviour();
}

Just make sure you name your submit inputs. The activated one will be the
only one which is successful.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Penny
Guest
 
Posts: n/a
#5: Jul 23 '05

re: How to make scripts for 2 submit buttons?


Thanks David,

Now I get it!

Regards

Penny


Closed Thread