c# - Cascading Dropdown in Javascript and can't get them in CodeBehind -
i have code in javascript cascading dropdown problem can't access data in codebehind in c# web.
this code in javascript:
function collegedepartment() { var s1 = document.getelementbyid("college"); var s2 = document.getelementbyid("department"); s2.innerhtml = ""; if (s1.value == "college of engineering") { var optionarray = ["civil engineering", "computer engineering", "electrical engineering", "electronics , communication engineering", "industrial engineering", "mechanical engineering"]; } else if (s1.value == "cas") { var optionarray = ["political science", "mascomm", "liacomm"]; } else if (s1.value == "commerce") { var optionarray = ["business ad", "hotel management", "tourism"]; } else if (s1.value == "education") { var optionarray = ["sped"]; } else if (s1.value == "cicct") { var optionarray = ["computer science", "information technology"]; } (var option in optionarray) { var newoption = document.createelement("option"); newoption.value = optionarray[option]; newoption.innerhtml = optionarray[option]; s2.options.add(newoption); } };
and have code in aspx:
<div class="form-group"> <select class="form-control" name="college" id="college" runat="server" oninput="collegedepartment()" style="width:300px;"> <option selected>select college</option> <option value="college of engineering">college of engineering</option> <option value="cas">colpxlege of arts , science</option> <option value="commerce">college of commerce</option> <option value="education">college of education</option> <option value="cicct">cicct</option> </select> </div> <div class="form-group"> <select id="department" name="department" class="form-control" runat="server" placeholder="department" style="width:300px;"> <option value="department" selected>select department</option> </select> </div>
how can access dynamic value of dropdown?
Comments
Post a Comment