I have three dropdownlists that I fill with the contents of viewbag variables. I want the content of the second variable to be filtered when I select a value of the first using JQuery or javascript. The same with the third dropdownlist, which is filtered by what is selected in the second.
function SelectedIndexChanged(accion, idnum) {
var nuevaSelProyecto = "";
var proyecto = "";
var nombre = "";
switch (idnum) {
case "ddlSelContrato": {
//var getValue = document.getElementById('ddlSelContrato').selectedOptions\[0\].value;
var e = document.getElementById("ddlSelContrato");
var getValue = e.options\[e.selectedIndex\].value;
nombre = "Contrato, indice seleccionado: " + getValue;
};
break;
case "ddlSelProyecto":
nombre = "Proyecto";
break;
case "ddlPtoStudio":
nombre = "Punto Estudio";
default:
nombre = "Defecto";
break;
}
alert("Alerta, indice: " + accion + " - " + nombre);
}
Contrato
@\*--------------------Listado desplegable de Contrato--------------------------\*@
@Html.DropDownList("ddlSelContrato", new SelectList(ViewBag.SelContrato, "Id", "Nombre"), new { Class = "ddlStyle", onchange = "SelectedIndexChanged(this.value ,id)" })
Proyecto
@\*--------------------Listado desplegable de Proyecto--------------------------\*@
@Html.DropDownList("ddlSelProyecto", new SelectList(ViewBag.SelProyecto, "Id", "Nombre"), new { Class = "ddlStyle", onchange = "SelectedIndexChanged(this.value ,id)"})
Punto de Medicion
@\*--------------------Listado desplegable de Puntos de estudio--------------------------\*@
@Html.DropDownList("ddlPtoStudi