I want to create a form that redirect the user to a different URL when they select an option from the select dropdown and click the submit button. Here is the markup for my form below:
<form>
<select>
<option selected="">- Select -</option>
<option value="https://google.com">One</option>
<option value="https://gmail.com">Two</option>
<option value="https://yahoo.com">Three</option>
</select>
<input type="submit" value="Submit">
</form>
4
Answers
You can do:
but if you use onclick as @Oriol Vilaseca suggested, you may need to prevent the submit event:
event.PreventDefault
This solution will work but not in the SO snippet:
SCRIPT PART :
HTML PART :