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查詢 –