U
UKuser
Hi,
I have the following code:
var images =
document.getElementById('map').getElementsByTagName('img');
for (i=0;i<images.length;i++){ // go through each image -
needed to be 0 - for NA
var t = images.id;
if (t != iPd){ // as long as the current image id is not the
one submitted
document.getElementById(t).src = "world/"+t
+"_normal.gif"; // correct
document.getElementById(t).onmouseout = function()
{swapImage(t,"out");};
document.getElementById(t).onmouseover = function()
{swapImage(t,"over");};
}
}
My problem is that only the final t (which happens to be the continent
Australia) gets set with the elements swapImage whereas I would have
assumed that as the loop went through, each t would be set
dynamically.
Can I therefore also clarify - does getElement(x).onmouseout - monitor
events or set them or both?
Earlier in my code I use the exact same lines outside the for loop and
it works fine. Slightly confused.
Many thanks
A
I have the following code:
var images =
document.getElementById('map').getElementsByTagName('img');
for (i=0;i<images.length;i++){ // go through each image -
needed to be 0 - for NA
var t = images.id;
if (t != iPd){ // as long as the current image id is not the
one submitted
document.getElementById(t).src = "world/"+t
+"_normal.gif"; // correct
document.getElementById(t).onmouseout = function()
{swapImage(t,"out");};
document.getElementById(t).onmouseover = function()
{swapImage(t,"over");};
}
}
My problem is that only the final t (which happens to be the continent
Australia) gets set with the elements swapImage whereas I would have
assumed that as the loop went through, each t would be set
dynamically.
Can I therefore also clarify - does getElement(x).onmouseout - monitor
events or set them or both?
Earlier in my code I use the exact same lines outside the for loop and
it works fine. Slightly confused.
Many thanks
A