Conditional submit of form?

M

M Wells

Hi All,

I'm trying to build a page where a user can enter comments and I want
to add a 'Preview' button to the form.

When the user clicks on the 'Preview' button I'd like the same form to
submit to the current page, however, when the user clicks on the
submit button, I'd like the form to submit to another processing page.

In other words, I basically want two distinct form actions -- one to
handle the click of the Preview button, the other to hand the click of
the Submit button.

If anyone can help me achieve this I'd appreciate it very much!

Many thanks in advance...

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.
 
L

lallous

Hello,

<input type='button' name='btnPreview' onclick='this.form.submit()'
value="Submit">
<input type='button' name='btnSubmit'
onclick='this.form.action="myAction.php"; this.form.submit()'
value="Submit">
 
M

M Wells

<input type='button' name='btnPreview' onclick='this.form.submit()'
value="Submit">
<input type='button' name='btnSubmit'
onclick='this.form.action="myAction.php"; this.form.submit()'
value="Submit">

Hi,

Thank you -- this was exactly what I was looking for!

Much warmth,

Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.
 
S

Stephen Poley

Thank you -- this was exactly what I was looking for!

Perhaps not what all your visitors are looking for though. As I just
mentioned in another thread, this results in the form being unusable for
anyone without Javascript (and potentially so for anyone with an unusual
Javascript dialect). Use input type=submit for the "real" submit button
and type=button (or a button element) for any nice-to-have extras.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top