How to make scripts for 2 submit buttons?

P

Penny

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.
 
R

Randy Webb

Penny said:
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?

It is better to let the server determine what to do with the page, in
case JS is disabled.
Is there a javascript to do this?

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

Penny

Hi Randy,
It is better to let the server determine what to do with the page, in
case JS is disabled.

By this do you mean use ASP/PHP or the like to determine which page to
redirect to?
<input type="submit" onclick="this.form.action='somePage.php'"
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
 
D

David Dorward

By this do you mean use ASP/PHP or the like to determine which page to
redirect to?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top