Multiple Submit buttons?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Multiple Submit buttons?

Post by angelicodin »

Hey ya guys. I've been working on this little project to learn how to do some things and I realized I could use it for a CMS I've been working on for a few months now.

One of the modules in the system is a blogger. And it's coming along, but I'm finding that I would like to have a preview function of some kind with the blog part of it.

So I did some poking around on goggle and what not to see how you can do more than one submit button and I got some answers but nothing that seemed to work for me.

Is there a simple way of setting up two submit buttons, like say one sends the data to one page and then another?
M2tM
Forum Commoner
Posts: 41
Joined: Sat Feb 27, 2010 12:35 pm

Re: Multiple Submit buttons?

Post by M2tM »

Yes. You'll have to use javascript and onclick to alter the target of the form.
<form id = "MyForm" action = "submit.php">
<input type = "submit" onclick = "document.getElementById('MyForm').action = 'preview.php';" name = "PreviewSubmit" value = "Preview"/>
<input type = "submit" name = "fullSubmit" value = "Submit"/>
</form>

Something like this is what you want.
User avatar
angelicodin
Forum Commoner
Posts: 81
Joined: Fri Nov 13, 2009 3:17 am
Location: Oregon, USA

Re: Multiple Submit buttons?

Post by angelicodin »

/cry

yeah that's what I thought. Been trying that but, don't know why, but with the rich text editor (also in java) and clears the information somehow.

Thanks for confirming this for me.
Post Reply