Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if i use only cascading DropDown list then its proper work... i want to show and hide div id depend upon list item of dropdown control... i do this task with onchange method but not working... but its work without cascading....

What I have tried:

       function CourseFun() {

           debugger

           var DropdownList = document.getElementById('<%=course.ClientID %>');

           var SelectedIndex = DropdownList.selectedIndex;
           var divEQ = document.getElementById('divEQ')
           var divtenper = document.getElementById('divtenper');
           var divyear10 = document.getElementById('divyear10');
           var divpertwelth = document.getElementById('divpertwelth');
           var divyearof12 = document.getElementById('divyearof12');
           var divgraper = document.getElementById('divgraper');
           var divyearofgra = document.getElementById('divyearofgra');

           if (SelectedIndex == 1) {
               divEQ.style.display = "block";
               divpertwelth.style.display = "block";
               divyearof12.style.display = "block";
               divgraper.style.display = "none";
               divyearofgra.style.display = "none";
               divyear10.style.display = "block";
               divtenper.style.display = "block";
           }
           else if (SelectedIndex == 3) {
               divEQ.style.display = "block";
               divpertwelth.style.display = "block";
               divyearof12.style.display = "block";
               divyear10.style.display = "block";
               divtenper.style.display = "block";
               divgraper.style.display = "none";
               divyearofgra.style.display = "none";
           }
           else if (SelectedIndex == 2) {
               divEQ.style.display = "block";
               divyearofgra.style.display = "block";
               divpertwelth.style.display = "block";
               divyearof12.style.display = "block";
               divyear10.style.display = "block";
               divtenper.style.display = "block";
               divgraper.style.display = "block";

           }

       }




<asp:DropDownList ID="course" runat="server"  class="slectbig" AutoPostBack="true" OnSelectedIndexChanged="course_SelectedIndexChanged" onChange="CourseFun()" >
    <asp:ListItem Value="0"> Select course
Posted
Updated 13-Mar-18 3:51am

1 solution

Setting AutoPostBack="true" means that the page will post back to the server as soon as you change the selected item.

The CourseFun function might run, but any changes it makes will be discarded.

You need to trigger the CourseFun function when the page loads instead.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900