onChange="Show(this.value)" <asp:DropDownList ID="ddlType" onChange="Show(this.value)" runat="server" CssClass="txt"
AutoPostBack="false">
<asp:ListItem Value="1">大专</asp:ListItem>
<asp:ListItem Value="2">本科</asp:ListItem>
<asp:ListItem Value="3">博士</asp:ListItem>
</asp:DropDownList>function Show(value) {
alert(value); if (value == "1") {
document.getElementById("1").style.display = "block";
document.getElementById("2").style.display = "none";
document.getElementById("3").style.display = "none";
}
if (value == "2") {
document.getElementById("1").style.display = "none";
document.getElementById("2").style.display = "block";
document.getElementById("3").style.display = "none";
}
if (value == "3") {
document.getElementById("1").style.display = "none";
document.getElementById("2").style.display = "none";
document.getElementById("3").style.display = "block";
}
}后台if(!ispostback) ddlType.SelectedIndex =Object.value; 分不多了,麻烦大家帮我看看,谢谢
AutoPostBack="false">
<asp:ListItem Value="1">大专</asp:ListItem>
<asp:ListItem Value="2">本科</asp:ListItem>
<asp:ListItem Value="3">博士</asp:ListItem>
</asp:DropDownList>function Show(value) {
alert(value); if (value == "1") {
document.getElementById("1").style.display = "block";
document.getElementById("2").style.display = "none";
document.getElementById("3").style.display = "none";
}
if (value == "2") {
document.getElementById("1").style.display = "none";
document.getElementById("2").style.display = "block";
document.getElementById("3").style.display = "none";
}
if (value == "3") {
document.getElementById("1").style.display = "none";
document.getElementById("2").style.display = "none";
document.getElementById("3").style.display = "block";
}
}后台if(!ispostback) ddlType.SelectedIndex =Object.value; 分不多了,麻烦大家帮我看看,谢谢
Literal1.Text="<script>Show('"+"this.Value对应的值"+"')</script>";也就是后台改变后,显式调用一次Show方法。根据需要,可以禁用Literal1的viewstate
测试 ie ff chrome 没问题啊
Page.ClientScript.RegisterStartupScript(this.GetType(), "show", "$(function(){show(1);});", true);
ddlType.Attributes["onchange"] = "Show(this.value);";
?能写具体点吗?拖到dropdownlist 后面?那怎么关联dropdownlist?