I have two dropdownlists: One is a list of countries, and the other is a list of states that will fill if either Canada or United States is called. I'm new to asp.net and Javascript, and would like someone to point in the right direction on what I am doing wrong. I'm just trying to set my ddl to the text at the moment to see how it works, and afterwards would like to fill the ddl with the lists in the javascript code. Thank you in advance!
<script>
function displayStateDDL() {
var ControlName = document.getElementById(ddlCountry.id);
if (document.getElementById("ddlCountry").value == "United States") {
document.getElementById("ddlState").value = "State";
} else if (document.getElementById("ddlCountry").value == "Canada") {
document.getElementById("ddlState").value = "Province";
}
}
</script>
<asp:DropDownList ID="ddlCountry" runat="server" Width="170px" onchange="javascript: displayStateDDL();">
</asp:DropDownList>
<asp:DropDownList ID="ddlState" runat="server" Width="170px"> </asp:DropDownList>