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

Conditional submit of form?

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


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

--
Elias
"M Wells" <pl**********@planetthoughtful.org> wrote in message
news:dk********************************@4ax.com...
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.

Jul 20 '05 #2

P: n/a
On Mon, 8 Dec 2003 14:52:34 +0200, "lallous" <la*****@lgwm.org> wrote:
<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.
Jul 20 '05 #3

P: n/a
On Thu, 11 Dec 2003 02:31:40 GMT, M Wells
<pl**********@planetthoughtful.org> wrote:
On Mon, 8 Dec 2003 14:52:34 +0200, "lallous" <la*****@lgwm.org> wrote:
<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">

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.

--
Stephen Poley
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.