I have a dropdown box with 4 options (Plus 1 default option)
I would like to force a redirect as soon as a specific dropdown option is chosen, but alow the other 3 to continue on with the form as normal.
Is this do-able?
I would like to force a redirect as soon as a specific dropdown option is chosen, but alow the other 3 to continue on with the form as normal.
Is this do-able?
Hi nuvelle,
Yes I think that you can do this with JavaScript. Listen to the onChange event for the drop-down and redirect if that value of the drop-down is selected. The code will be something like this:
Bob
Yes I think that you can do this with JavaScript. Listen to the onChange event for the drop-down and redirect if that value of the drop-down is selected. The code will be something like this:
window.addEvent('domready', function() {
$('drop_down_id').addEvent('change', function() {
if ( $('drop_down_id').value == 'redirect' ) {
window.location = 'http://some_domain.com';
}
});
});Bob
Please forgive my newbieness.
My scenario is to trigger a redirect to a URL http://www.yahoo.com
upon a drop down value of 'Irvine' being selected.
The drop down menu field id is called 'input_select_2'
I created a new action called on Change and pasted your code below in it.
I assume this is the appropriate step. If not please advise.
Because I am new to code and syntax, what exactly should my code look like in the on Change action?
Thank You
your example:
My scenario is to trigger a redirect to a URL http://www.yahoo.com
upon a drop down value of 'Irvine' being selected.
The drop down menu field id is called 'input_select_2'
I created a new action called on Change and pasted your code below in it.
I assume this is the appropriate step. If not please advise.
Because I am new to code and syntax, what exactly should my code look like in the on Change action?
Thank You
your example:
window.addEvent('domready', function() {
$('drop_down_id').addEvent('change', function() {
if ( $('drop_down_id').value == 'redirect' ) {
window.location = 'http://some_domain.com';
}
});
});
Hi marklaudens,
You don't need a new event; just drag a Load JS action into the On Load event of your form.
The code I posted should work but you need to update the specific details for your form:
Bob
PS Why would you redirect to Yahoo?? just curious.
You don't need a new event; just drag a Load JS action into the On Load event of your form.
The code I posted should work but you need to update the specific details for your form:
window.addEvent('domready', function() {
$('input_select_2').addEvent('change', function() {
if ( $('input_select_2').value == 'Irvine' ) {
window.location = 'http://www.yahoo.com';
}
});
});Bob
PS Why would you redirect to Yahoo?? just curious.
GreyHead, A big thank You!!
I just used Yahoo as an example. Ultimately I want to redirect to any URL I choose, but needed to understand the syntax mechanics.
Cheers
marklaudens
I just used Yahoo as an example. Ultimately I want to redirect to any URL I choose, but needed to understand the syntax mechanics.
Cheers
marklaudens
This topic is locked and no more replies can be posted.
