Hi, I want to use a "for loop" to shorten the coding for the "if....." part only, but I am not sure how to...
//I am tring this but..
for (var m=1;m<4;m++)
{
if(horse[m].style.posLeft>800)
{
alert(m+"..horse won the race")
}

}


could anyone help me?



Thanks

PHP Code:
 <script
var 
sstop=setInterval("run()",50
function 
run() 

document.getElementById("horse1"); 
document.getElementById("horse2"); 
document.getElementById("horse3"); 
document.getElementById("horse4"); 
horse1.style.posLeft=horse1.style.posLeft+(Math.random()*10)+1
horse2.style.posLeft=horse2.style.posLeft+(Math.random()*10)+1
horse3.style.posLeft=horse3.style.posLeft+(Math.random()*10)+1
horse4.style.posLeft=horse4.style.posLeft+(Math.random()*10)+1
if(
horse1.style.posLeft>800

alert("horse1 won the race"
horse1.style.posLeft=10
horse1.style.posLeft=horse1.style.posLeft+(Math.random()*0)+1
//.................... 
//............... 


</
script
<
img src="horse.gif" id=horse1 style="position:absolute;top:200;left:10;"
<
img src="horse.gif" id=horse2 style="position:absolute;top:230;left:10;"
<
img src="horse.gif" id=horse3 style="position:absolute;top:260;left:10;"
<
img src="horse.gif" id=horse4 style="position:absolute;top:290;left:10;"