R
Robi
I have the following problem:
I populate a page with a specific amount of <div id="MyTest"> containers inside another <div> container.
for (i=0; i < MyString.length; i++)
document.write('<div id="MyTest"
style="position:absolute;top:0px;left:0;height:12;width:12;text-align:center">'+MyString+'</div>');
Now if MyString contains 6 characters, I end up with 6 <div id="MyTest"> containers.
With IE I am able to access these containers as follows:
for (i=0; i < MyString.length; i++) {
var Obj=MyTest.style;
Obj.top=NewPositionTop;
Obj.left=NewPositionLeft+i;
}
Now with Firefox this didn't work
Javascript Error: file:///c:/test/mytest.js, line 209: MyTest has no properties
and the Javascript Console suggests:
Warning: Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.
so I decided to use getElementById(), but keep getting errors.
I tried:
Obj1=document.getElementById("MyTest");
and then access Obj1.style.top/left but
Javascript Error: file:///c:/test/mytest.js, line 210: Obj1 has no properties
I also tried Obj=document.getElementById("MyTest").style;
with the same result.
What is it that keeps me from accessing a specific entry in the getElementById("MyTest") list/array?
can anyone point me in the right direction?
Thanks, Robi
I populate a page with a specific amount of <div id="MyTest"> containers inside another <div> container.
for (i=0; i < MyString.length; i++)
document.write('<div id="MyTest"
style="position:absolute;top:0px;left:0;height:12;width:12;text-align:center">'+MyString+'</div>');
Now if MyString contains 6 characters, I end up with 6 <div id="MyTest"> containers.
With IE I am able to access these containers as follows:
for (i=0; i < MyString.length; i++) {
var Obj=MyTest.style;
Obj.top=NewPositionTop;
Obj.left=NewPositionLeft+i;
}
Now with Firefox this didn't work
Javascript Error: file:///c:/test/mytest.js, line 209: MyTest has no properties
and the Javascript Console suggests:
Warning: Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead.
so I decided to use getElementById(), but keep getting errors.
I tried:
Obj1=document.getElementById("MyTest");
and then access Obj1.style.top/left but
Javascript Error: file:///c:/test/mytest.js, line 210: Obj1 has no properties
I also tried Obj=document.getElementById("MyTest").style;
with the same result.
What is it that keeps me from accessing a specific entry in the getElementById("MyTest") list/array?
can anyone point me in the right direction?
Thanks, Robi