-
Reference an object
Hi
Can anyone help me with something that is confusing me...
I know that in javascript you can reference a HTML object by using:
document.all['blah'] etc
but it i want to dynamically reference the object for example
var strValue = 'divInfo';
document.all[strValue]
I am unable to do this
Can anyone suggest why this might be the case?
Thanks in advance
Sarah
-
It should work. Are you sure the element exists?
But document.all is IE-only!
document.getElementById(<id>) is better.
-
yes, use getElementById(). if it still esn't working, please tell us what the rror is and what browser you get the error with?