I have a two dropdown list on my web application. The populated data of two dropdown comes from a database. They contain the same data.
What I want is if one of the list is selected on the first dropdown, it should not be available on the second dropdown anymore.
I have the following razor syntax:
@Html.DropDownListFor(model => model.Questions1, (SelectList)ViewData["Questions"], "Select>>", new { id = "Questions1", Name = "Questions1"})
@Html.DropDownListFor(model => model.Questions2, (SelectList)ViewData["Questions"], "Select>>", new { id = "Questions2", Name = "Questions2"})
The Questions came from the model which is retrieve from the database.
Thanks in advance!
selectelement in JavaScript and remove any matchingoptionfrom the otherselect. You'd just want to store the values in another structure as well in order to re-add them when the value changes again.