Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > HTML, XHTML and CSS

Reply
 
LinkBack Thread Tools
Old October 10th, 2007, 04:40 PM   #1
Highly Reputable Member
 

Join Date: Jul 2006
Location: Devon, England
Posts: 564
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 AdRock will become famous soon enough
[SOLVED] 2 different actions, same form

I have a form where I can add BBCode to a textarea and on it is 3 buttons. 2 of them are submit buttons and the other is a reset button

One of the submit buttons is a Submit button and the other is a Preview button.

I would like the Submit button to do one action like saving the record in a database (which is pretty straightforward) but I want the Preview button to do exactly what it says on the tin.....Preview whatever is in textarea.

How do I go about having 2 different actions depending on which button is pressed? My first and only thought is JavaScript but I have no clue as I've never needed to do this before
AdRock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 10th, 2007, 04:42 PM   #2
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
Re: 2 different actions, same form

Can you send the POST info to the preview page and then pass it on to the other in PHP?
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 10th, 2007, 04:49 PM   #3
Highly Reputable Member
 

Join Date: Jul 2006
Location: Devon, England
Posts: 564
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 AdRock will become famous soon enough
Re: 2 different actions, same form

That would be OK if I wanted to preview the post first but what if I wanted to just POST the data straight into the database
AdRock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 10th, 2007, 04:54 PM   #4
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 17
Posts: 3,799
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
Re: 2 different actions, same form

Yeah, just send the it to the preview page, and then pass it on. So it just goes through the preview page.
Like so:
form - > preview (put posted data into hidden input fields) -> into database page
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 11th, 2007, 01:58 PM   #5
Highly Reputable Member
 

Join Date: Jul 2006
Location: Devon, England
Posts: 564
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 AdRock will become famous soon enough
Re: 2 different actions, same form

Would something like this work

HTML Code:
<input type="submit" name="update" value="Update"> 
<input type="submit" name="delete" value="Delete">

Then using php
Code:
if (isset($_POST['update'])) 

//do something 

if (isset(
$_POST['delete'])) 

//do something 

AdRock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 11th, 2007, 02:02 PM   #6
Highly Reputable Member
 

Join Date: Apr 2007
Location: Willich, Germany
Age: 22
Posts: 592
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 c010depunkk is a jewel in the rough c010depunkk is a jewel in the rough c010depunkk is a jewel in the rough c010depunkk is a jewel in the rough
Re: 2 different actions, same form

That should work just fine. Test it to make sure....
c010depunkk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PHP contact form redirect to same form Posie PHP 14 January 29th, 2008 04:28 PM
One form, two actions? skuliaxe HTML, XHTML and CSS 1 January 23rd, 2008 10:05 AM
Need Help With Flash Actions manny4003 Flash and ActionScript 6 July 5th, 2007 07:17 PM
Two form actions on pressing submit button? AndyP HTML, XHTML and CSS 7 July 25th, 2005 12:25 PM
text actions benbacardi Flash and ActionScript 1 May 14th, 2004 06:14 PM


Search Engine Optimization by vBSEO 3.2.0 RC8