There is a form, optionally from a drop-down list, it sends to handlers, but sends it immediately after choosing from the list. There are options for how to make it go to the handler page only after clicking Submit?

<form action="" method="post" class="form" id="red"> <select id="country" class="dropdown_2"> <option value="" disabled="disabled" selected="selected">Country</option> <option value="http://...vara.html">var A</option> <option value="http://...varb.html">">Var B</option> </select> 

 <script> $(function() { $('#country').on('change', function() { var url = $(this).val(); if (url) { window.location = url; } return false; }); }); </script> 
  • This line $('#country').on('change', function() { means that when you change the selector, the code is executed. If you want the code to be executed when you click on the submit, you need to write it like this: $('id кнопки').on('click', function() { - Dmitriy Kondratiuk

1 answer 1

I solved the question using the method: I cleaned the script - I hooked onclick straight to the submission.

 <input type="submit" value="GO" onclick = "window.location=document.forms[0].country.options[document.forms[0].country.selectedIndex].value" />