<script>
function SelectType()
{
var panel1=document.getElementById( "Panel1 ");
var panel2=document.getElementById( "Panel2 ");
var list=document.getElementById( "list ");
var v=list.options[list.selectedIndex].text;
if(v== "panel1 ")
{
alert( "Panel1 ");
panel2.visible=false;
panel1.visible=true;
}
if(v== "panel2 ")
{
alert( "Panel2 ");
panel1.visible=true;
panel2.visible=false;
}
}
</script>
------
page_load
---
if (!IsPostBack)
{
list.Items.Add( "panel1 ");
list.Items.Add( "panel2 ");
list.Attributes.Add( "onchange ", "SelectType() ");
}
-----------------------
alert事件可以執行,但是panel沒有反應~~????
------解决方案--------------------------------------------------------
panel.style.display = "none ";
------解决方案--------------------------------------------------------
隐藏
panel.style.display = "none ";
显示
panel.style.display = " ";
------解决方案--------------------------------------------------------
panel2.visible=false;
panel1.visible=true;
------------------------
这是ASP.NET的写法,不是JS的写法:
try:
function SelectType()
{
var panel1=document.getElementById( " <%=Panel1.ClientID> ");
var panel2=document.getElementById( " <%=Panel2.ClientID> ");
var list=document.getElementById( " <%=list.ClientID> ");
var v=list.options[list.selectedIndex].text;
if(v== "panel1 ")
{
alert( "Panel1 ");
panel2.style.display= "none ";
panel1.style.display= "block ";
}
if(v== "panel2 ")
{
alert( "Panel2 ");
panel1.style.display= "none ";
panel2.style.display= "block ";
}
}
------解决方案--------------------------------------------------------