Multiple submit button forms

S

Sims

Hi,

I have a form that allows the user to update some of their records.
To make it easier the form has been split into 2 pages.

So I have 2 forms, (one for each pages).
But after updating the first page the user might be ready to save the data
rather than going thru the next page.

So how could I have 2 buttons one that would send the user to page 2, (to
continue editing). And another that would send me straight to the finished
section where the data is saved.

Thanks in advance.

Sims
 
B

brucie

in post: <
Sims said:
So I have 2 forms, (one for each pages). But after updating the first
page the user might be ready to save the data rather than going thru
the next page.
So how could I have 2 buttons one that would send the user to page 2, (to
continue editing). And another that would send me straight to the finished
section where the data is saved.

two submit buttons. "save and exit" "save and continue" the action your
stript takes depending on which button is pressed.

"save and exit" does just that. "save and continue" saves and rather
than exiting brings up the next form. simple.
 
S

Sims

two submit buttons. "save and exit" "save and continue" the action your
stript takes depending on which button is pressed.

"save and exit" does just that. "save and continue" saves and rather
than exiting brings up the next form. simple.

But the action is defined in the <form ...>, the button does not say where
the form should go next...
<input type='submit' ...>

Or did I miss something in the way my forms are done?

Sims
 
B

brucie

in post: <
But the action is defined in the <form ...>,

yes, the action being a server side script
the button does not say where the form should go next...
<input type='submit' ...>

it doesn't need to. get your server side script to have a look at the
value of the submit button when the form goodies are sent to the server.
depending on the value of the submit button depends on what actions the
server side script performs.

Or did I miss something in the way my forms are done?

i think so.
 
G

Guest

Sims said:
So how could I have 2 buttons one that would send the user to page 2, (to
continue editing). And another that would send me straight to the finished
section where the data is saved.

Thanks in advance.

Sims

It depends on if server-side programming is an option for you.

If it's server side, just use two submit buttons (or a checkbox, etc..)
The logic on the server side script determines what to do based on the
presence or state of the form variable.

If server side stuff simply isn't an option, or the program design won't
allow it, there is another trick that works only with javascript.

Use javascript buttons (and javascript) to alter the ACTION portion of
the form, and then use javascript to submit it, depending on which button
was pressed. This has some advantages in that javascript can prevent the
same data from being submitted twice. (Sometimes shopping carts will do
this on a checkout form to prevent double-triple orders. (and credit
card charges)

Has the disadvantage that, well.. it's javascript and won't work on all
browsers, can be a mess to deal with, etc..

Jamie
 
M

Mark Parnell

It depends on if server-side programming is an option for you.

How do you plan to process the form without some sort of server-side
script? OK, it may be a pre-built one that you can't modify, but that's
a different issue.
 
G

Guest

Mark Parnell said:
How do you plan to process the form without some sort of server-side
script? OK, it may be a pre-built one that you can't modify, but that's
a different issue.

Thanks for the correction.

Should have read "If modification of server side program"....

Jamie
 
S

Sims

If it's server side, just use two submit buttons (or a checkbox, etc..)
The logic on the server side script determines what to do based on the
presence or state of the form variable.

If server side stuff simply isn't an option, or the program design won't
allow it, there is another trick that works only with javascript.

Use javascript buttons (and javascript) to alter the ACTION portion of
the form, and then use javascript to submit it, depending on which button
was pressed. This has some advantages in that javascript can prevent the
same data from being submitted twice. (Sometimes shopping carts will do
this on a checkout form to prevent double-triple orders. (and credit
card charges)

Has the disadvantage that, well.. it's javascript and won't work on all
browsers, can be a mess to deal with, etc..

Thanks, my problem was far simpler, I didn't know that I could have more
than one "type='submit'" button.

Sims
 

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,811
Messages
2,569,693
Members
45,477
Latest member
IsidroSeli

Latest Threads

Top