0
Greetings friends of Stack Overflow!
I’m having a cruel doubt in Javascript/Jquery
that is consuming me more time than I would like (heh!) - I would like to filter one Dropdownlist
based on the options of another Dropdownlist
.
The image below represents more or less what I’m struggling to do!
Here’s the HTML part that does this:
<div class="form-group col-sm-3">
<label>Nome do cadastro:</label>
@Html.DropDownListFor(m => m.FinancialItems, new SelectList(Model.FinancialItems, "Description", "Description"),
new { @id = "nomeCadastro", @class = "form-control" })
</div>
This class searches the data directly from the database and fills it there with a simple "toList()".
I’m using Javascript
, JQuery
, and C#
with MVC5
.
It is possible to do this directly on JS/JQuery
? (If there is a API/Plugin
that deals with it, also serves!
Thank you!!!!!!!!!
Would that be something like that? https://answall.com/a/76296/20615
– Randrade
How are you populating that Dropwdown? some viewbag data? is static ? put the code there please.
– Leonardo Bonetti
Randrade: I’ll try it later, maybe I can solve it, although it sounds a bit complex for a function that looks so simple! @Leonardobonetti I’m populating the data via a list that pulls them directly from the comic book. I will edit my description with the code used in Dropdownlist.
– Momentanius
@Momentanius Beauty, I’ll tell you how you do it ;)
– Leonardo Bonetti
Dude, I would indicate you put the second dropdown on a partial and when selecting the first dropdown, you would have a function that would send the selected option to your controller and there you would filter the data you want to have on the second dropdown, would send to your screen the partial of the second dropdown and overwrite it on the screen. Later, if I have to, I’ll put what you asked for in an example.
– Ayrton Giffoni
Financialitems has an attribute with reference to its first dropdown index?
– Leandro Angelo