Forums

Change submit action based on select value

BNRBranding 02 Jul, 2014
I need to submit a form to different URLs based on the value of a select field, this is what I have that is not working.

window.addEvent('domready', function() {
    $('gender').addEvent('onchange', function() {
        if('gender'.value=='male') {
		 document.id('chronoform_consultation-Copy').action ='male.html';
	} else {
		document.id('chronoform_consultation-Copy').action ='female.html';	
	}
    });
});


What am I missing?
GreyHead 03 Jul, 2014
Hi BNRBranding,

MooTools leaves out the 'on' prefix to event names so this line
$('gender').addEvent('onchange', function() {
needs to be
$('gender').addEvent('change', function() {


Bob
BNRBranding 03 Jul, 2014
Duh. It's always the simple things. That fixed it.

Thanks Bob.
This topic is locked and no more replies can be posted.