0
知道一点Javascript是希望有人能帮助我。根据DDL中的值,我试图让DIV显示。Javascript显示DIV的DDL值
这是我到目前为止有:
<asp:DropDownList ID="SearchTypeDDL" runat="server" onchange="searchType();" Width="150px">
<asp:ListItem Enabled="true" Text="Select Search type" Value="-1"></asp:ListItem>
<asp:ListItem Text="Coordinates" Value="1"></asp:ListItem>
<asp:ListItem Text="Postcode/Town" Value="2"></asp:ListItem>
</asp:DropDownList>
的Javascript:
function searchType() {
var ddl = document.getElementById("<%=SearchTypeDDL.ClientID %>");
if (ddl.selectedIndex == '1') {
$('#coordinates').show();
} else {
$('#coordinates').hide();
}
}
编辑:
新增警报检查值传递:
var ddl = document.getElementById("ddl");
var SelectedIndex = ddl.selectedIndex;
alert(SelectedIndex);
if (ddl.selectedIndex == '1') {
$('#coordinates').show();
} else {
$('#coordinates').hide();
}
警报是sho翼'1',但它跳过了IF声明