0
我有选择下拉列表给它一个空的问题,而选择了它后选择下拉列表选项显示隐藏的文本框
下面是代码:
<asp:GridView ID="gridview1" runat="server" AllowPaging="false" Width="99%" >
<asp:BoundField DataField="NAME" HeaderText ="Name" HtmlEncode="false"/>
<asp:BoundField DataField="ID " HeaderText ="ID " HtmlEncode="false"/>
<asp:TemplateField HeaderText ="Location">
<ItemTemplate>
<asp:DropDownList ID="ddlfruitAgent" runat="server" onchange="Store_Location_onChange(this)" />
<asp:TextBox ID="StoreLocation" runat="server" TextMode="MultiLine" Rows="2" style="width:97%;display:none" />
</ItemTemplate>
</asp:TemplateField>
的javascript:
function Store_Location_onChange(objThis) {
if (objThis.value == "0") {
document.getElementById("StoreLocation").style.display = "";
}
else {
document.getElementById("StoreLocation").value = "";
document.getElementById("StoreLocation").style.display = "none";
}
}
它有一个错误的JavaScript运行时错误:无法设置定义或空引用属性值 而我尝试选择下拉列表 –
控制台这一行' - > objThis.nextElementSibling'并查看返回的是什么! –
下拉列表是后面的代码是一个SQL查询 –