By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,827 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,827 IT Pros & Developers. It's quick & easy.

How to make scripts for 2 submit buttons?

P: n/a
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.
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Penny wrote:
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">

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2

P: n/a
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

Jul 23 '05 #3

P: n/a
Penny wrote:
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?


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
Jul 23 '05 #4

P: n/a
Thanks David,

Now I get it!

Regards

Penny
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.