Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with for-statement

Status
Not open for further replies.

safra

Technical User
Jan 24, 2001
319
NL
Hi,

I have a page with 5 div's (div1, div2, div3, div4, div5). I would like to reset style settings with a for-statement. I can't find the right syntax to do this (target the div's).

I am not so good in this sort of stuff, this is one of the things I tried:

for(i=0;i<5;i++){
if(i!=num){
[&quot;div&quot;+i].style.background = &quot;#ffffff&quot;;
}
}

I also tried eval for the specific part, didn't work neither.

Can somebody tell me what to change, please?

Ron

 
for(i=0;i<5;i++){
if(i!=num){
[&quot;div&quot;+i].style.background = &quot;#ffffff&quot;;
}
}


What is that highlighted line for? I would think that if you want to reset all divs, that you just loop through all five, and not have to have a condition. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
the part you highlighted is there because one of the five items should remain intact. the other 4 should be reset to color white. But how?

The syntax above results in errors!

Ron
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top