G
G
groovie2018-03-04 01:34:18
JavaScript
groovie, 2018-03-04 01:34:18

How, when choosing a certain option, reset the value of adjacent child inputs, selects?

There is one parent select that has many different options. In addition to the parent select, there are a bunch of other selects and simple inputs that are children of the parent select. They hide and appear when a particular option is selected from the parent select. That is, they chose one option from the parent select, selects and inputs intended specifically for this option appear, they chose another option - other selects and inputs appear. So. How can I make sure that when one option is selected from the main select, the values ​​of other children that have already been selected are reset? In general, when selecting a certain option from the parent select, you need to reset the value of all other child selects and inputs, but not those whose option is currently selected in the main in the parent select.
The description, of course, turned out to be “break your brain”, but I don’t know how else to explain or how to show an example ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Skibin, 2018-03-04
@megafax

In the same condition where you are "hiding" / "showing" the necessary elements - add zeroing the rest. You can select them by condition (example with jQuery)
Where show-hide-elements is for Everyone (class according to your taste), and in the not condition - list the current ones.
Or, since the elements are hidden - add disabled to them, if this does not contradict the application logic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question