i am working two dropdown in which dropdownList1 contain mutilpe bind id and second contain the one bind id .it will be work fine means value are change on first dropdown change. follwing the drop down and js now it will be clear.
dropdownlist
<asp:DropDownList ID="DropDownList1" runat="server" Height="19px" Width="149px">
<asp:ListItem>--Select--</asp:ListItem>
<asp:ListItem Value="1,45,43">Bank</asp:ListItem>
<asp:ListItem Value="2,545,45">country</asp:ListItem>
<asp:ListItem Value="3,657,434">city</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" Height="18px" Width="151px">
<asp:ListItem>--Select--</asp:ListItem>
<asp:ListItem Value="1">bank1</asp:ListItem>
<asp:ListItem Value="1">ban2</asp:ListItem>
<asp:ListItem Value="2">pakistan</asp:ListItem>
<asp:ListItem Value="2">India</asp:ListItem>
<asp:ListItem Value="3">islambad</asp:ListItem>
Js Function:
window.onload = function () {
var parentSelect = document.getElementById("DropDownList1");
var childSelect = document.getElementById("DropDownList2");
var options = [].slice.apply(childSelect, [0]);
var emptyOption = options[0];
childSelect.innerHTML = "";
childSelect.options.add(emptyOption);
parentSelect.addEventListener("change", function (e) {
for (var i = 0; i < parentSelect.options.length; ++i) {
if (parentSelect.options[i].selected == true) {
var setaccudccode = new Array();
var setall = new Array();
setall = parentSelect.options[i].value.split(',');
var selectedValue = setall[0];
childSelect.innerHTML = "";
childSelect.options.add(emptyOption);
if (selectedValue == 0) return;
}
}
for (var i = 0; i < options.length; i++) {
if (options[i].getAttribute("value") == selectedValue) {
childSelect.options.add(options[i]);
}
}
});
return false;
};
problem is that i want to use multiple id bind with the second drop downList please help me how i solve it.i want it will be work on that senrio.please help me.
<asp:DropDownList ID="DropDownList1" runat="server" Height="19px" Width="149px">
<asp:ListItem>--Select--</asp:ListItem>
<asp:ListItem Value="1,45,43">Bank</asp:ListItem>
<asp:ListItem Value="2,545,45">country</asp:ListItem>
<asp:ListItem Value="3,657,434">city</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server" Height="18px" Width="151px">
<asp:ListItem>--Select--</asp:ListItem>
<asp:ListItem Value="1,567">bank1</asp:ListItem>
<asp:ListItem Value="1,890">ban2</asp:ListItem>
<asp:ListItem Value="2,780">pakistan</asp:ListItem>
<asp:ListItem Value="2,789">India</asp:ListItem>
<asp:ListItem Value="3,67,67">islambad</asp:ListItem>
means the second dropdown having multiple value and it will be shown on run time.please help me how i solve it using java script function.