You are here: irt.org | FAQ | JavaScript | Form | 7.2 | Q128 [ previous next ]
In Netscape you can change the action attribute of a form with:
document.formName.action = 'whatever';
All you need to do is trap which option is selected:
document.formName.selectName.options[document.formName.selectName.selectedIndex].value;
The following brings it all together:
<SCRIPT LANGUAGE="JavaScript"><!--
function setAction() {
if (navigator.appName.indexOf('Netscape') > -1) {
document.formName.action = document.formName.selectName.options[document.formName.selectName.selectedIndex].value;
return true;
}
else {
alert('Sorry, your browser does not support the changing of the action property of a form');
return false;
}
}
//--></SCRIPT>
<FORM NAME="formName" ACTION="????????" METHOD="POST" onSubmit="return setAction()">
<SELECT NAME="selectName">
<OPTION SELECTED VALUE="yes.html">Yes
<OPTION VALUE="no.html">No
</SELECT>
<INPUT TYPE="SUBMIT">
</FORM>