here is the form

<form id="w0" method="get" action="найти"> <input type="text" placeholder="Поиск" value="" name="query"> <div class="form-group"> <button onclick="window.location.href=this.form.action+'-'+this.form.query.value" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> 

I get when I click on the button here is the address http://film.lc/%найти?query=запрос find?query http://film.lc/%найти?query=запрос if I do so

 <form id="w0" method="get" action="найти"> <input type="text" placeholder="Поиск" value="" name="query"> <div class="form-group"> <button onclick="alert(window.location.href=this.form.action+'-'+this.form.query.value)" type="submit"> <i class="fa fa-search"></i> </button> </div> </form> 

Then after a while, if you do not click on the window alert window.location.href will work and I will get this address http://film.lc/ find- request. Why the first form does not work does not tell me how to deal with it

    1 answer 1

    The button type="submit" . When clicking on the button in this case, the form is sent, so it seems that the onclick handler in which the location changes does not work.

    In the case of an alert, the main processing loop is inhibited when the alert is executed, the parameter that is calculated and changed location.

    The meaning of such a handler is not entirely clear. Or you need to replace type="submit" with type="button" , or remove onclick