Javascript下拉列表没有响应
Javascript dropdownlist doesn't respond
表单一开始就隐藏了。当我选择窗口,窗体应该是可见的,但它没有。我试图添加一个if-else语句,如果没有匹配,它将显示警报,但这也不起作用。我猜它永远不会着火。有人知道为什么吗?
代码如下:
<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>
我找到了一个解决方案,我只需要添加
document.getElementById("<%=DropDownListForm.ClientID%>");
相关文章:
- 如何使用jQuery选择下拉列表的值
- 将jsp文件下拉列表中的选定项分配给一个java变量(比如String selection)
- Javascript按钮下拉列表
- jQuery表单添加不适用于下拉列表
- 用每小时的差值填充数组/列表-从下拉列表中给定两个时间值
- 禁用jQuery中的下拉列表
- 如何在按钮中显示下拉列表中选定的元素
- 如何在从多选下拉列表中选择选项值时动态生成文本框
- 响应式引导按钮,输入组中带有下拉列表
- 来自服务器的响应未显示在 Select2 下拉列表中
- 如何在 jQuery 中用 JSON 数据填充下拉列表作为 ajax 响应
- 如何使用 jQuery 提取作为 AJAX 响应接收的 JSON 数据并将其添加到 HTML 选择下拉列表中
- 将数据绑定到 kendo 下拉列表时,如何将 ajax 响应数据获取到变量
- 没有响应.chzn-select两个带有ajax和codeigniter的下拉列表
- Twitter Bootstrap Rails按钮下拉列表没有响应AJAX
- 如何从Web API服务获取数据-无法通过淘汰JS加载带有API响应的下拉列表
- 用货币的json响应数据填充下拉列表
- 下拉列表中未设置 AJAX 响应 JSON 数据
- Javascript下拉列表没有响应
- Jquery 和 ajax 不响应级联下拉列表