two submit buttoms for a form ?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
rekha_harnoor
Forum Commoner
Posts: 32
Joined: Mon Feb 19, 2007 3:17 am

two submit buttoms for a form ?

Post by rekha_harnoor »

Can I give two submit buttoms for a form?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I know a quicker way to find out than posting on a forum!
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Yes, you can.

You will need to give each of them the same name, then do what you want with the form depending on the value of the submit button.

Code: Select all

<input type="submit" name="submit" value="Preview" />
<input type="submit" name="submit" value="Post" />

<?php

//proccessing form
switch($_POST['submit'])
{
   case 'Preview':
   //process for preview
   break;

   case 'Post':
   //process for post
   break;
}

?>
At least, that's how I do it.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply