I have a basic shopping cart setup, currently the user clicks a button
to remove an item from the cart. The form action posts to itself in
order to update the item list.
Is it possible to have another button in the same form that posts to a
different location?
Please hold your comments if they're not constructive. I am aware of
the existence of Google, it just hasn't worked for me here.
Thanks
Re: Two Submit buttons on one form
am 12.01.2008 13:56:22 von Paul Lautman
ktstone2678@gmail.com wrote:
>I have a basic shopping cart setup, currently the user clicks a button
> to remove an item from the cart. The form action posts to itself in
> order to update the item list.
>
> Is it possible to have another button in the same form that posts to a
> different location?
Yes, but you have to use javascript to change the form's action field value.
Re: Two Submit buttons on one form
am 12.01.2008 14:14:17 von luiheidsgoeroe
On Sat, 12 Jan 2008 13:40:39 +0100, wrote:
> I have a basic shopping cart setup, currently the user clicks a button
> to remove an item from the cart. The form action posts to itself in
> order to update the item list.
>
> Is it possible to have another button in the same form that posts to a
> different location?
>
> Please hold your comments if they're not constructive. I am aware of
> the existence of Google, it just hasn't worked for me here.
Javascript would work, but is unreliable.
Why not post to a page, that on the basis of said button, includes one or
the other script? Or a check at the top of the script that possible
decides to include another one and then exits?
--
Rik Wasmus
Re: Two Submit buttons on one form
am 12.01.2008 14:28:08 von webmasterNOSPAMTHANKS
*** ktstone2678@gmail.com escribió/wrote (Sat, 12 Jan 2008 04:40:39 -0800
(PST)):
> I have a basic shopping cart setup, currently the user clicks a button
> to remove an item from the cart. The form action posts to itself in
> order to update the item list.
>
> Is it possible to have another button in the same form that posts to a
> different location?
>
> Please hold your comments if they're not constructive. I am aware of
> the existence of Google, it just hasn't worked for me here.
I'll personally give buttons a name and make them all submit to self page
(see sample code on bottom). Then, check which name exists and act
accordingly: header('Location: ...') is your friend.
Make sure it's cross browser (IE has some problems if buttons are
type="image") and make sure of what happens when user hits the "enter" key.
"http://www.w3.org/TR/html4/loose.dtd">
echo '$_POST: '; var_dump($_POST); echo '';
?>
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor austrohúngaro: http://www.demogracia.com
--
Re: Two Submit buttons on one form
am 12.01.2008 19:31:30 von axlq
In article <8285a830-6c14-44bf-ae55-84122934817b@t1g2000pra.googlegroups.com>, wrote:
>I have a basic shopping cart setup, currently the user clicks a button
>to remove an item from the cart. The form action posts to itself in
>order to update the item list.
>
>Is it possible to have another button in the same form that posts to a
>different location?
Why would you want to do that? Why not just have the second submit
button post to the same location? Two submit buttons on the same
form can perform two different functions. I do this all the time.
The buttons have different value parameters, the php script picks up
on which one was clicked, and acts accordingly.
If you want two buttons in the same form to post to different
locations, you need javascript to modify the form URL. Not a good
idea, IMO, to rely on javascript when you don't have to.
-A
Re: Two Submit buttons on one form
am 13.01.2008 02:20:55 von ktstone2678
On Jan 12, 1:31 pm, a...@spamcop.net (axlq) wrote:
> In article <8285a830-6c14-44bf-ae55-841229348...@t1g2000pra.googlegroups.com>,
>
> wrote:
> >I have a basic shopping cart setup, currently the user clicks a button
> >to remove an item from the cart. The form action posts to itself in
> >order to update the item list.
>
> >Is it possible to have another button in the same form that posts to a
> >different location?
>
> Why would you want to do that? Why not just have the second submit
> button post to the same location? Two submit buttons on the same
> form can perform two different functions. I do this all the time.
> The buttons have different value parameters, the php script picks up
> on which one was clicked, and acts accordingly.
>
> If you want two buttons in the same form to post to different
> locations, you need javascript to modify the form URL. Not a good
> idea, IMO, to rely on javascript when you don't have to.
>
> -A
Ideally that's would I would like to do. I need to do research on how
to accomplish that , but I think that's the best solution. Thanks for
you advice everyone
Re: Two Submit buttons on one form
am 13.01.2008 02:59:06 von ktstone2678
On Jan 12, 8:20 pm, ktstone2...@gmail.com wrote:
> On Jan 12, 1:31 pm, a...@spamcop.net (axlq) wrote:
>
>
>
> > In article <8285a830-6c14-44bf-ae55-841229348...@t1g2000pra.googlegroups.com>,
>
> > wrote:
> > >I have a basic shopping cart setup, currently the user clicks a button
> > >to remove an item from the cart. The form action posts to itself in
> > >order to update the item list.
>
> > >Is it possible to have another button in the same form that posts to a
> > >different location?
>
> > Why would you want to do that? Why not just have the second submit
> > button post to the same location? Two submit buttons on the same
> > form can perform two different functions. I do this all the time.
> > The buttons have different value parameters, the php script picks up
> > on which one was clicked, and acts accordingly.
>
> > If you want two buttons in the same form to post to different
> > locations, you need javascript to modify the form URL. Not a good
> > idea, IMO, to rely on javascript when you don't have to.
>
> > -A
>
> Ideally that's would I would like to do. I need to do research on how
> to accomplish that , but I think that's the best solution. Thanks for
> you advice everyone
I wanted to post the solution for anyone else who might stumble across
this thread, turns out to be very simple.
Re: Two Submit buttons on one form
am 13.01.2008 03:12:59 von luiheidsgoeroe
On Sun, 13 Jan 2008 02:59:06 +0100, wrote:
> On Jan 12, 8:20 pm, ktstone2...@gmail.com wrote:
>> On Jan 12, 1:31 pm, a...@spamcop.net (axlq) wrote:
>
Which, depending on which statistic one believes, would not work for 5% =
- =
15% of your visitors. Also, If you're going to use javascript, ask in =
comp.lang.javascript for best practises.
-- =
Rik Wasmus
Re: Two Submit buttons on one form
am 13.01.2008 06:53:30 von thyb0
axlq wrote:
> If you want two buttons in the same form to post to different
> locations, you need javascript to modify the form URL. Not a good
> idea, IMO, to rely on javascript when you don't have to.
I agree, PHP could handle it, just post the form to a single script which
will redirect to your desired location. In order to do this, I think you
could use CURL to re-submit the form data to the desired location, or just
think twice about it and hu.. I don't know.. ask the user to verify the data
he just entered and re-submit it itself =P. It's always worth it anyway !
The function is recursive and reproduces form-generated arrays so you don't
miss a thing; but you can just rewrite the form manually as well.
The output buffer is there by (good?) habit, not absolutely needed.
Of course, you can also pass the serialized & encoded $_POST via $_GET,
process it and then directly redirect the user or reload the page without
the $_GET (and thus don't process anything after reload) but I think you
might be limited in the size of the form.
Good luck ^^'.
-thib´
Re: Two Submit buttons on one form
am 13.01.2008 23:01:51 von Michael Fesser
..oO(ktstone2678@gmail.com)
>I wanted to post the solution for anyone else who might stumble across
>this thread, turns out to be very simple.
>
>
That's no solution. You really don't want to do that.
Do it server-side.
Micha
Re: Two Submit buttons on one form
am 14.01.2008 00:58:20 von Jerry Stuckle
ktstone2678@gmail.com wrote:
> On Jan 12, 8:20 pm, ktstone2...@gmail.com wrote:
>> On Jan 12, 1:31 pm, a...@spamcop.net (axlq) wrote:
>>
>>
>>
>>> In article <8285a830-6c14-44bf-ae55-841229348...@t1g2000pra.googlegroups.com>,
>>> wrote:
>>>> I have a basic shopping cart setup, currently the user clicks a button
>>>> to remove an item from the cart. The form action posts to itself in
>>>> order to update the item list.
>>>> Is it possible to have another button in the same form that posts to a
>>>> different location?
>>> Why would you want to do that? Why not just have the second submit
>>> button post to the same location? Two submit buttons on the same
>>> form can perform two different functions. I do this all the time.
>>> The buttons have different value parameters, the php script picks up
>>> on which one was clicked, and acts accordingly.
>>> If you want two buttons in the same form to post to different
>>> locations, you need javascript to modify the form URL. Not a good
>>> idea, IMO, to rely on javascript when you don't have to.
>>> -A
>> Ideally that's would I would like to do. I need to do research on how
>> to accomplish that , but I think that's the best solution. Thanks for
>> you advice everyone
>
> I wanted to post the solution for anyone else who might stumble across
> this thread, turns out to be very simple.
>
>
>
Yep, and it fails for me and about 10-15& of the rest of the world
because we browse with javascript disabled.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Two Submit buttons on one form
am 14.01.2008 04:45:24 von ktstone2678
thib` - excellent post, thanks so much for taking the time to help.
Awesome