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.
Submitted On | |
By | Dave Vroman |
Level | Intermediate |
User Rating | 4.5 (18 globes from 4 users) |
Compatibility | |
Category | Controls/ Forms/ Graphics/ Menus |
World | Java |
Archive File |
<font size=3>
<pre><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>
</pre></font>