S
S
supershpion2020-04-27 17:40:12
HTML
supershpion, 2020-04-27 17:40:12

Why are the values ​​of the select tag reset on the event onchange="location.reload();" in google chrome?

there is a select

<select class="form-control" id="loanEnd" onchange="location.reload();">
   <option value="0">Выбрать...</option>
   <option value="1">Один</option>
   <option value="2">Два</option>
   <option value="3">Три</option>
</select>


When any option value is selected, its value is passed to the js script that performs certain actions. So for some reason in firefox everything works without problems, i.e. when you select any option, the page is updated without a full reload and the selected option data remains in the same form, retaining its value, however, in Google Chrome, as well as in other browsers, when using the location.reload () method, the page is completely reloaded (although it should not), all selected option values ​​are reset and, accordingly, the script has nothing to process. I have already tried all the variations of using the location methods, it does not help. What is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-04-27
@Rsa97

location.reload() works like a page reload button in a browser. The behavior of input fields on reload is determined by the browser itself and by installed extensions (for example, those that save form data).
Use AJAX to update information on the page without reloading, or store the data in localStorage/sessionStorage for the duration of the reload.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question