presci :
write a event onchange and check for the selected index and
document.forms[0].action='blah';
or
document.forms[0].action=document.forms[0].selectbox.options[selectbox.selectedIndex].value;
On Jun 15, 9:02 am, Arthur <Art...@nospam.comwrote:
Hello.
How might it be possible to change where a form action is directed based on
a selected option.
For example I have this:
<FORM METHOD = "post" ACTION = "">
And a drop down such as
<Select name="formaction">
<option value="method1">method1</option>
<option value="method2">method2</option>
</select>
If option 1 is selected I need this to happen
<FORM METHOD = "post" ACTION = "http://www.thisdomain.com">
If option 2 is selected I need this to happen
<FORM METHOD = "post" ACTION = "http://www.thatdomain.com">
Thanks.
.................................................. .................................................. ........................
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>
</title>
<script type="text/javascript">
/**
* I thing that this
* way is much elegant
* than document.forms[0].action
* =document.forms[0].
* selectbox.options[selectbox.selectedIndex].value;
* @author Georgi Naumov
*/
function changeAction(aForm,aValue)
{
if(aValue=="")
return;
aForm.setAttribute("action",aValue);
}
</script>
</head>
<body>
<div>
<form action="somewhere.php" action="blanc.php">
<select name="myselect"
onchange="changeAction(this.form,this.value);">
<option value="">plese select action</option>
<option value="one.php">one</option>
<option value="three.php">three</option>
</select>
</form>
</div>
</body>
</html>