2011-06-10 56 views
0

嗨我有一个下拉列表和更新面板里面的div。我想在更新面板中的dropdownlist选择更改上使用javascript切换div。但它不起作用。如何使用javascript在更新面板内切换div。 asp.net

function DistrictChange() { 
     debugger; 
     var ddldistrict = document.getElementById('<%=DDLDistrict.ClientID %>'); 
     var dvOther = document.getElementById('<%=divOthrDistrict.ClientID %>'); 
     if (ddldistrict.options[ddldistrict.selectedIndex].text == 'Other') { 
      dvOther.style.display == 'block'; 

     } 
     else { 
      dvOther.style.display == 'none'; 
     } 

    }  
+0

粘贴完整代码 – Saurabh 2011-06-10 09:14:58

+0

请分享你的代码片段里面做它(即使失败) – mkilmanas 2011-06-10 09:15:24

+2

dvOther.style.display ==“无”; 必须是 dvOther.style.display ='none'; – 2GDev 2011-06-10 09:17:22

回答

0

问题是这行代码:

dvOther.style.display == 'none'; 

==是比较的语句。

使用此为任务:

dvOther.style.display = 'none';