使用onchange方法不能使用级联下拉列表

使用onchange方法不能使用级联下拉列表

本文介绍了使用onchange方法不能使用级联下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我只使用级联DropDown列表然后它正常工作...我想显示和隐藏div id取决于下拉控件的列表项...我用onchange方法执行此任务但不工作...但它的没有级联的工作....



我尝试过:



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

推荐答案


这篇关于使用onchange方法不能使用级联下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 20:22