PDA

View Full Version : variables in NS4 DOM...some working, 1 NOT


ChuckRW
11-23-2002, 03:16 AM
Hi folks,
Ofcourse, I have a perfect code solution for IE and NS7. In NS4.6, however, I have a problem
The problem is in bright red. When I use the name, ‘orange01’, of the image whos source is to be switched everything works fine. When I use the variable rollName it fails. The other variable curDiv and rollSource work fine. Why?
I need to use a variable for the image name, how can I do this?


THIS WORKS
<style type="text/css">
#shell01 {
position: absolute;
left: 1;
}
#div01 {
position: relative;
}
</style>
<script>
function overCol01(curDiv, rollName, rollSource) {
document.layers['shell01'].layers[curDiv].document.orange01.src=rollSource;
}
</script>
<div id="shell01" id="shell01">
<div id="div01" id="div01">
<a href="#" onmouseover="overCol01('div01', 'orange01', 'orangelit.gif');"><img border="0" id="orange01" name="orange01" src="orangedark.gif"></a>
</div>


THIS DOES NOT WORK
<style type="text/css">
#shell01 {
position: absolute;
left: 1;
}
#div01 {
position: relative;
}
</style>
<script>
function overCol01(curDiv, rollName, rollSource) {
document.layers['shell01'].layers[curDiv].document.rollName.src=rollSource;
}
</script>
<div id="shell01" id="shell01">
<div id="div01" id="div01">
<a href="#" onmouseover="overCol01('div01', 'orange01', 'orangelit.gif');"><img border="0" id="orange01" name="orange01" src="orangedark.gif"></a>
</div>

beetle
11-23-2002, 08:00 AM
That's because you are literally trying to find an object named 'rollName' and NOT an object with the name of the string stored in rollName. Use the images collection for this..

document.layers['shell01'].layers[curDiv].document.images(rollName).src=rollSource;

I think that's right....

ChuckRW
11-24-2002, 05:59 AM
AHHHHH...thats one of the billions of things I tried, BUT I used the word image instead of images.
Thanks!...off to give it a whirl.
Chuck