BritMiss
08-23-2003, 09:50 AM
What I'm trying to do here is cycle different images at different places on the screen. Earlier versions of this script worked fine randomly positioning a random image but this version always writes the image to the top left of the screen. Can anybody see why? and can you suggest a solution?
Pic=new Array("Eye1.gif","Eye2.gif","Eye3.gif","Eye4.gif")
display=new Array(4)
for (x=0; x<7; ++x) { //----------------------------------------------count columns across
display[x]=new Array(4)
for (y=0; y<4; ++y) { //-------------------------------------------------and rows down
gif=parseInt(Math.random()*3) //---------------------choose a number less than 4
display[x][y]=Pic[gif] // ---------------choose a picture at random for this cell
}
}
for (x=0; x<7 ; ++x) {
for (y=0; y<4 ; ++y) {
x=parseInt(Math.random()*7) // -----------------------------random whole numbers
y=parseInt(Math.random()*4)
Top=y*100
Left=x*200
line='<DIV ID ="Eye" STYLE="position:absolute" top='+top+' left='+Left+' width=200 height=100><IMG SRC="'+display[x][y]+'" border=0></DIV>'
document.write(line)
Pic=new Array("Eye1.gif","Eye2.gif","Eye3.gif","Eye4.gif")
display=new Array(4)
for (x=0; x<7; ++x) { //----------------------------------------------count columns across
display[x]=new Array(4)
for (y=0; y<4; ++y) { //-------------------------------------------------and rows down
gif=parseInt(Math.random()*3) //---------------------choose a number less than 4
display[x][y]=Pic[gif] // ---------------choose a picture at random for this cell
}
}
for (x=0; x<7 ; ++x) {
for (y=0; y<4 ; ++y) {
x=parseInt(Math.random()*7) // -----------------------------random whole numbers
y=parseInt(Math.random()*4)
Top=y*100
Left=x*200
line='<DIV ID ="Eye" STYLE="position:absolute" top='+top+' left='+Left+' width=200 height=100><IMG SRC="'+display[x][y]+'" border=0></DIV>'
document.write(line)