Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to make scripts for 2 submit buttons?

Reply
Thread Tools

How to make scripts for 2 submit buttons?

 
 
Penny
Guest
Posts: n/a
 
      06-11-2005
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.


 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      06-11-2005
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
 
Reply With Quote
 
 
 
 
Penny
Guest
Posts: n/a
 
      06-11-2005
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



 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      06-11-2005
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
 
Reply With Quote
 
Penny
Guest
Posts: n/a
 
      06-13-2005
Thanks David,

Now I get it!

Regards

Penny


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Using Python Scripts with IIS - ASP or Python-based CGI scripts withIIS - which makes more sense? davidj411 Python 0 06-27-2008 04:38 PM
What is required for perl scripts to run correct when launched from rc scripts on HPUX 11? deanjones7@gmail.com Perl Misc 13 09-10-2007 11:58 AM
Stupid question: Making scripts python-scripts Jan Danielsson Python 8 07-22-2005 12:20 AM
Re: Stupid question: Making scripts python-scripts Jp Calderone Python 0 07-21-2005 02:38 PM



Advertisments