读书人

javascript怎么给控件(input type=quot;te

发布时间: 2012-04-13 13:50:24 作者: rapoo

javascript如何给控件(input type="text")赋值,要兼容IE和Firefox
我前台定义了一个input控件

HTML code
<td width="10%" align="right">                <input id="NickName" type="text" visible="false" runat="server" />            </td>

用javascript给该控件赋值
JScript code
document.getElementById("NickName").value = res;

结果用firebug发现这个错误,不知道为什么,求助!
JScript code
document.getElementById("NickName") is null


[解决办法]
<input id="NickName" type="text" visible="false" runat="server" />

隐藏掉了页面上就不存在了,可以这样隐藏 style='display:none'

[解决办法]
用document.forms["NickName"]试试

读书人网 >C#

热点推荐