Sunday, 15 February 2015

javascript - Redirect specific options of a select box -



javascript - Redirect specific options of a select box -

i have select box users needs select in form. first options, deed normal, lastly 2 options needs redirect users on page if selects them.

so far have this

<script> function redirect(what) { var index = what.selectedindex; var value = what.options[index].value; if (value != 7) return; window.location.href='http://www.example.com'; } </script>

but need add together redirection.

if users selects alternative 7, redirect example.com if users selects alternative 8, redirect google.com

how can ?

if (value != 7 && value != 8) return; if (value == 7){ window.location.href='http://www.example.com'; }else if (value == 8){ window.location.href='http://www.example.com/2'; } }

javascript html

No comments:

Post a Comment