Forum Moderators: open

Message Too Old, No Replies

document.getElementByID('') problems in IE

         

will1480

6:20 am on May 7, 2004 (gmt 0)

10+ Year Member



I am trying to make my div boxes absolute positioned when hidden, then relatively positioned and visible.

sample:
function hide_boxes(){
temp=document.form1.menu1.value;
for(i=1;i<=5;i++){
document.getElementById("div"+i).style.position='absolute';
document.getElementById("div"+i).style.visibility='hidden';
}
setTimeout("show_boxes()",100);
}
function show_boxes(){
temp=document.form1.menu1.value;
for(i=1;i<=temp;i++){
document.getElementById("div"+i).style.position='relative';
document.getElementById("div"+i).style.visibility='visible';
}
}

this works fine in NS, It works in IE except it does not change the div box back to visible. Is there some kind of limited access to div style in IE. Any other ways to accomplish this would be great as well.

Bernard Marx

8:54 am on May 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm having no trouble with your code in IE.
It doesn't even mind if the value returned by the form element is in fact a string.

Is there some kind of limited access to div style in IE.

Not that I've heard of.

Any other ways to accomplish this would be great as well.

That all depends what 'this' is :)

If you want the boxes to disappear and also not take up any space, the standard approach would be not to bother with visibility / position, but toggle the 'display' property instead.

will1480

1:25 pm on May 7, 2004 (gmt 0)

10+ Year Member



My javascript knowledge has been humbled. Not sure why I didnt know about 'dsiplay', but that was exactly what I was trying to accomplish. Works the exact same as what I was doing, but simpler and crossbrowser. Thank you for your input.

Bernard Marx

1:34 pm on May 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't let it be humbled, most of what you are doing involves scripting the W3C DOM, not core Javascript objects. No one can be expected to learn everything all at once.