![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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... (AT) nospam (DOT) com> wrote: 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. |
|
/** * I thing that this * way is much elegant * than document.forms[0].action * =document.forms[0]. * selectbox.options[selectbox.selectedIndex].value; * @author Georgi Naumov |
#4
| |||
| |||
|
|
Georgi Naumov said the following on 6/16/2007 5:04 PM: 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... (AT) nospam (DOT) com> wrote: 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. snipped lots of XHTML that it takes a person of a particular mental capacity to serve on the web /** * I thing that this * way is much elegant * than document.forms[0].action * =document.forms[0]. * selectbox.options[selectbox.selectedIndex].value; * @author Georgi Naumov You think wrong. .................................................. ................................... |
|
-- Randy Chance Favors The Prepared Mind comp.lang.javascript FAQ - http://jibbering.com/faq/index.html Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ |
#5
| |||
| |||
|
|
Randy Webb : You think wrong. Why ? This: aForm.setAttribute("action",aValue); is shorter than: document.forms[0].selectbox.options[selectbox.selectedIndex].value; |
#6
| |||
| |||
|
|
Randy Webb : Georgi Naumov said the following on 6/16/2007 5:04 PM: 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... (AT) nospam (DOT) com> wrote: 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. snipped lots of XHTML that it takes a person of a particular mental capacity to serve on the web /** * I thing that this * way is much elegant * than document.forms[0].action * =document.forms[0]. * selectbox.options[selectbox.selectedIndex].value; * @author Georgi Naumov You think wrong. .................................................. .................................. Why ? |
|
This: aForm.setAttribute("action",aValue); is shorter than: document.forms[0].selectbox.options[selectbox.selectedIndex].value; |
![]() |
| Thread Tools | |
| Display Modes | |
| |