leechun
05-18-2003, 04:45 PM
hello helpful people:
thanks for all your inputs regarding my previous post on "loop, layers and images". you have been most helpful:) after some Brain squeezing, i have came up with a solution that works, i thought i might share this with you and maybe you can provide some feedback. ok, here it goes....
/*create layers using loop like this*/
var img_name = "sec_img";
var div_name = "sec";
var img_full_name;
var div_full_name;
var index;
for(index=0;index<somevalue; index++)
{
div_full_name = div_name + index;
img_full_name = img_name + index;
document.write('<div id = '+div_full_name+' style = "position:absolute;top:0px;left:0px">');
document.write('<img id = '+img_full_name+'>');
document.write('</div>')
}
/*then alter aspects of the imges like this*/
function change_img_src()
{
var rand = Math.floor(Math.random() * 100) % 2;
var img_name = "sec_img";
var img_full_name = img_name + ((Math.floor(Math.random() * 100) % somevalue) + 1);
if(rand) eval(img_full_name).src = img1.src;
else eval(img_full_name).src = img2.src;
timer4 = setTimeout("change_img_src()", 500);
}
I apologise in advance if this method seem a bit brutal;)
peace,
CHUN
thanks for all your inputs regarding my previous post on "loop, layers and images". you have been most helpful:) after some Brain squeezing, i have came up with a solution that works, i thought i might share this with you and maybe you can provide some feedback. ok, here it goes....
/*create layers using loop like this*/
var img_name = "sec_img";
var div_name = "sec";
var img_full_name;
var div_full_name;
var index;
for(index=0;index<somevalue; index++)
{
div_full_name = div_name + index;
img_full_name = img_name + index;
document.write('<div id = '+div_full_name+' style = "position:absolute;top:0px;left:0px">');
document.write('<img id = '+img_full_name+'>');
document.write('</div>')
}
/*then alter aspects of the imges like this*/
function change_img_src()
{
var rand = Math.floor(Math.random() * 100) % 2;
var img_name = "sec_img";
var img_full_name = img_name + ((Math.floor(Math.random() * 100) % somevalue) + 1);
if(rand) eval(img_full_name).src = img1.src;
else eval(img_full_name).src = img2.src;
timer4 = setTimeout("change_img_src()", 500);
}
I apologise in advance if this method seem a bit brutal;)
peace,
CHUN