0
表單已經隱藏在開頭。當我選擇窗口時,窗體應該變得可見,但它不會。我試圖添加一個if-else語句,如果沒有匹配,它會顯示警報,但這也不起作用。我猜想它永遠不會開火。任何知道知道爲什麼?Javascript dropdownlist不響應
下面是代碼:
<asp:Content ID="Content2" ContentPlaceHolderID="HeaderContent" Runat="Server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function DropDownlistOptions() {
var dropdownlist = document.getElementById("DropDownListForm");
var selected = dropdownlist.options[dropdownlist.selectedIndex].value;
if (selected == "Window") {
document.getElementById("WindowForm").style.visibility = "visible";
}
else {
alert("failed");
}
}
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Content1" Runat="Server">
<asp:DropDownList ID="DropDownListForm" runat="server" onchange="DropDownlistOptions()">
<asp:ListItem Selected="True">Please Select</asp:ListItem>
<asp:ListItem>Window</asp:ListItem>
<asp:ListItem>Linux</asp:ListItem>
</asp:DropDownList>
<div id="WindowForm" style="visibility:hidden;">
Form info to fill.....
</div>
</asp:Content>