Reputation: 11
I have a code that gives me the item selected in a dropdownlist but I can´t make it work for a dropdowncheckbox. In the following:
var Activity= document.getElementById("Cbo_ActivityTypes").value
var Brand = document.getElementById("Cbo_Brand").value
Alert (Activity)
Alert (Brand)
Alert (activity) shows a window with the ID of the item selected, but the Alert(Brand) shows a windows saying undefined. It doesn't recognize that there were items selected in the field Brand.
Codes that load each box:
asp:DropDownList ID="Cbo_ActivityType" runat="server" Width="143px" AutoPostBack="True">
asp:DropDownCheckBoxes ID="Cbo_Brand" runat="server" Width="180px" UseSelectAllNode="False">
Anyone can give some help on this issue?
Upvotes: 0
Views: 763
Reputation: 1235
It is an asp webControl. So to get your Id in html use '<%=ID.ClientID%>'
var Activity= document.getElementById("<%=Cbo_ActivityTypes.ClientID%>").value
var Brand = document.getElementById("<%=Cbo_Brand.ClientID%>").value
Upvotes: 1