It turns out that I have a need to create a tag <select>
that controls the selection of another tag <select>
. That is, my selected option displays a list of different options in the other.
What I have to do is that when a user selects a type of schedule, select
the same value is not replicated in the next one, example:
This would come on my first select
05:00 - 06:00
06:00 - 07:00
07:00 - 08:00 <-- Assuming I choose this option
This should appear in my second select
05:00 - 06:00
06:00 - 07:00
Is it possible to do it with a simple script?
I am developing the page in jsp
and html
...
Sure, you can easily do it with jquery. In the onChange event when you know which option was selected, you can get the elements that haven't been selected
'option:not(:selected)'
and clone them in the second select.for jquery you can capture every time its option changes, a function is executed, in this case the following
This way, every time you change the option, it will perform the function that lies where it says "//Execute the action to perform". I hope this guides you
Greetings and success in your work!