article

Multiple Submit Buttons On Forms

Email
Submitted on: 1/2/2015 6:00:00 PM
By: Dave Vroman (from psc cd)  
Level: Intermediate
User Rating: By 4 Users
Compatibility:
Views: 1575
 
     This script allows multiple forms to support multiple submit buttons that do different things. The case in point one button does a submit while the other button does a named PopUp (selecting another option from the original window does not open a new window but goes back to the PopUp window) It is currently being selected to do a popup of a map so that the end user can make an informed decision of the addresses displayed in the form and select the correct one.

 
				
<HTML><HEAD>
<TITLE>Multiple Submit Buttons On Forms</TITLE>
</HEAD><BODY>
<SCRIPT LANGUAGE="JavaScript"><!--
function DoSubmit(url, inVal, name, FormsNum) {
 if ( inVal == 'Pop' ) {
popupWin = window.open(url, name);
 } else {
// Be careful of the forms number
document.forms[FormsNum].action = url
document.forms[FormsNum].method = "POST"
document.forms[FormsNum].submit()
 }
}
//-->
</SCRIPT>
<FORM>
<CENTER>
<SELECT SIZE=5>
<OPTION VALUE=0 SELECTED>Option 1
<OPTION VALUE=1>Option 2
<OPTION VALUE=2>Option 3
<OPTION VALUE=3>Option 4
<OPTION VALUE=4>Option 5
</SELECT>
<BR>
<INPUT TYPE="BUTTON" VALUE=" Submit 1 "
OnClick="javascript:DoSubmit('a.htm','OK',' ',0)">
<INPUT TYPE="BUTTON" VALUE="Show Popup 1"
OnClick="javascript:DoSubmit('b.htm','Pop','PopWinName',0)">
</CENTER>
</FORM>
<FORM>
<CENTER>
<SELECT SIZE=5>
<OPTION VALUE=0 SELECTED>Option 1
<OPTION VALUE=1>Option 2
<OPTION VALUE=2>Option 3
<OPTION VALUE=3>Option 4
<OPTION VALUE=4>Option 5
</SELECT>
<BR>
<INPUT TYPE="BUTTON" VALUE=" Submit 2 "
OnClick="javascript:DoSubmit('c.htm','OK',' ',1)">
<INPUT TYPE="BUTTON" VALUE="Show Popup 2"
OnClick="javascript:DoSubmit('d.htm','Pop','PopWinName',1)">
</CENTER>
</FORM>
</BODY></HTML>
<html><body>
<!-- Save this as a.htm, b.htm, c.htm and d.htm -->
This is a.htm
</body></html>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.