Contact Form 7 Conditional redirect based on drop-down menu
-
I have the following script
<script type=”text/javascript”>
document.addEventListener( ‘wpcf7mailsent’, function( event ) {
var redirector = $(“select[name=number]”).val();
if(redirector == ‘1’ ){
location = ‘https://facebook.com’;
}
else if(redirector == ‘5’ ){
location = ‘https://youtube.com’;
}
else if(redirector == ’10’ ){
location = ‘https://twitter.com’;
} else {
location = ‘https://myspace.com’;
}
}, false );
</script>I don’t understand why it’s not doing what it’s supposed to. It’s supposed to redirect after submission to a website depending on the selection you make on the drop-down menu, however, it does not.
So for example, when I select number 10 in the drop-down menu (the dropdown menu ID is “number”) and click submit, it’ll redirect me to twitter.
- The topic ‘Contact Form 7 Conditional redirect based on drop-down menu’ is closed to new replies.