i posted another question about this, but i think this one will be more concise.
i’ve dynamically created a text field with javascript. i’ve checked to see that it’s in the DOM by getting its value, but when trying to access it from another function i get a value of null for the input object. is it actually possible to get the current value from a dynamically created text field?
inside one function:
comment_field = 'comment-HE382U3-2'; document.getElementById(comment_field).value = 'Write a comment...';
inside the other:
comment_field = 'comment-HE382U3-2';
if (document.getElementById(comment_field).value == 'Write a comment...')
{ document.getElementById(comment_field).value = '';}
is not happening because there is no [HTMLInputObject] found in the DOM. Please help. Thanks!
Yes. It is just like any other element. If it is in the DOM, it is accessed the same way.
Verify the value of the
comment_fieldvariable. You’re making reference to different functions, so perhaps that variable is out of scope.