经典 ASP/VBScript 创建隐藏输入字段
我正在执行 VBScript 循环,并尝试连接一个字符串,然后将其加载到隐藏输入字段的值中。
response.write("<input type='hidden' name='strWPL' value='" & strTest & "'/>")
我已经验证 strTest 中确实有数据,并且我已经验证在服务器完成处理后 strWPL 存在。
但是,当我添加此代码时:
<script language="javascript" type="text/javascript">
$(window).load(function () {
alert(document.getElementById('strWPL').value);
});
</script>
我收到一条错误,指出 strWPL 为 NULL。但是,当我在 Firebug 中搜索该元素时,它就在那里。
您可能需要了解的另一个重要信息是该屏幕位于 iFrame 中。我不确定这是否有影响。
我做错了什么?
I am doing a VBScript loop and I am attempting to concatenate a string which then would be loaded into the value of a hidden input field.
response.write("<input type='hidden' name='strWPL' value='" & strTest & "'/>")
I have verified that strTest does have data in it and I have verified that strWPL exists after the server is done processing.
However, when I add this code in:
<script language="javascript" type="text/javascript">
$(window).load(function () {
alert(document.getElementById('strWPL').value);
});
</script>
I get an error stating that strWPL is NULL. However, when I search for the element in Firebug it is there.
The other nugget of info you might need to know is that this screen is in an iFrame. I'm not sure if that makes a difference or not.
What am I doing incorrectly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在按 ID 查找元素,但您仅设置隐藏输入字段的名称,这是不一样的。您还需要设置 id 属性。修改您的代码以按如下方式编写输入,并且假设没有其他情况发生,它应该可以工作。
You're looking for Element by ID, but your are only setting the name of the hidden input field, which is not the same. You need to set the id attribute as well. Modify your code to write the input as so, and it should work assuming nothing else is going on.