Replication of cascading dropdowns when updating / reverse navigation with autocomplete

Some browsers support auto-completion of forms by default. Therefore, when updating a page that has been partially (or completely) completed, the browser will save the field values.

My problem is that when I have cascading dropdowns like this:

Choose your car:
* Make a drop-down list * Drop-down list of models
* Year of dropdown menu

... and the user is updated or returns to this form from another page, the first one is filled (since it does not depend on any other values), the next two are empty, because they are filled when the previous drop-down lists are changed.

I figured out how to refill the model, since it is just a matter of determining the value for Make and calling Ajax to repopulate the model.

However, since the browser is trying to set the value on the model before I remember it, I will lose the original value.

Is there a way in javascript to grab previously selected values ​​when the page loads so that I can populate these cascading dropdowns correctly?

+4
source share

Source: https://habr.com/ru/post/1380420/


All Articles