我在页面定义了一个输入框:
<asp:TextBox ID="txtCountryID" Runat="server" Width="10" Visible=False>0</asp:TextBox>
注意,我设置一个Visible=False。
然后我在OnLoad的JS事件中,用了以下语句:
function loadme()
{
alert(document.forms[0].txtCountryID.value);
}
这样,报错说“document.forms.0.txtCountryID.value为空或不是对象”如果我把Visible=False去掉就可以了,为什么呢?
JS是不是换一种写法就可以了?谢谢
<asp:TextBox ID="txtCountryID" Runat="server" Width="10" Visible=False>0</asp:TextBox>
注意,我设置一个Visible=False。
然后我在OnLoad的JS事件中,用了以下语句:
function loadme()
{
alert(document.forms[0].txtCountryID.value);
}
这样,报错说“document.forms.0.txtCountryID.value为空或不是对象”如果我把Visible=False去掉就可以了,为什么呢?
JS是不是换一种写法就可以了?谢谢
不显示,但document生成
alert(document.forms[0].txtCountryID.value);
else
alert('啊哈');