Classic ASP/VBScript creating a hidden input field
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 () {
开发者_如何学JAVA 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?
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.
response.write("<input type='hidden' name='strWPL' id='strWPL' value='" & strTest & "'/>")
精彩评论