[RESOLVED] Two Submit Buttons for One Form
Hi guys,
I have an HTML form which needs two submit buttons. (Pushing one will submit the form data to "insert_info.php" and the other to "publish.php.")
I have attempted to use javascript to switch the form action attribute to "insert_info.php" when one submit button is pushed, and "publish.php" when the other is pushed, but this fix appears to require that the form have a name attribute. However, the name attribute is not valid in XHTML Strict.
Does anyone have any suggestions on how to get two submit buttons for one form while maintaining valid XHTML Strict? One solution that looked quite promising and that I think is used in Wordpress involves the "hidden" attribute. Does this ring a bell?
Here's the form code:
HTML Code:
<form method="post" name="form">
<p>
Title: <input type="text" name="title"/>
</p>
<p>
Meta Tags: <textarea rows="10" cols="30" name="meta"></textarea>
</p>
<p>
Header 1: <input type="text" name="header_1"/>
</p>
<p>
Paragraph 1: <textarea rows="10" cols="30" name="paragraph_1"></textarea>
</p>
<p>
Header 2: <input type="text" name="header_2"/>
</p>
<p>
Paragraph 2: <textarea rows="10" cols="30" name="paragraph_2"></textarea>
</p>
<p>
Author: <input type="text" name="author"/>
</p>
<p>
<input type="submit" name="save" value="Save" onclick="javascript: form.action='http://www.thesiteguru.com/php/insert_info.php';"/>
<input type="submit" name="publish" value="Publish" onclick="javascript: form.action='http://www.thesiteguru.com/php/publish.php';"/>
</p>
</form>
So the Name Attribute Is Superfluous...
Ah, I see. So the name attribute for the form tag is not needed even when using this javascript. I deleted that, Charles, and made the other changes you suggested, and my form validates! Thanks a lot.
Mr. Baggins
------
I don't know half of you half as well as I should like; and I like less than half of you half as well as you deserve. - Bilbo in The Fellowship of the Ring