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!

2 questions about loops...

Status
Not open for further replies.

mackey333

Technical User
May 10, 2001
563
US
ok here is my loop:

Code:
function startLoop() {

	num = 96

	for (i=0; i<num; i++) {
	
		iShow = i++
	
		document.getElementById('divMover + i').style.visibility = 'hidden';
		document.getElementById('divMover + iShow').style.visibility = 'visible';
	
	}
		
}

this loop is supposed to go through and hide the division divMover with whatever number i is (if i is 3 it hides the division divMover3), then show the div with the value of i plus 1..I'm guessing that I didn't put that string together right because it dosen't work. Also is there away to set a timeout to make it wait before the next cycle through?

-Greg
 
No, annoying I know - the timeout seems to be set, and then the next line is executed. Another problem you might have is getting different delays (if you want them). What you could do though, is put all the relevant info in an Array - so it is obtainable from your single index.

To make the string work use something like:
document.getElementById('divMover' + i).style.visibility = 'hidden';
the integer should be converted automatically.


The other thing that may be happening is incrementing i twice, if this happens just put iShow = (i+1);
b2 - benbiddington@surf4nix.com
 
oh..nevermind I just saw it..the i var. is still in the string..oops...

-Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top