DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums  

Go Back   DevHunters.com l Webmaster Forum - Web Advertising - Web Design - SEO Forums > Webmaster / Coding / Web Design Discussion > JavaScript Programming

JavaScript Programming Discuss javascript coding.

Have A Look At Some Of Our Webmaster Related Sponsors!


Script Directory


Shopping Cart


Market Leverage


Free Templates

3D Guide-Characters
3D Guide-characters

social bookmarking network
Advertise Here

Reply
 
LinkBack Thread Tools Display Modes
Old 03-15-2008, 07:25 AM   #1 (permalink)
New Hunter
 

Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
Smiggy will become famous soon enoughSmiggy will become famous soon enough
Send a message via MSN to Smiggy
Default Stuck!!

How do you get this to loop:

Code:
function expand(id)
{
	var layer = document.getElementById(id).style;
	if(i != 60)
		{
			i += 1;
			layer.width = i + "%";
		}
	time = setTimeout("expand(" + id + ")", 1000)
}
I can't get it to start the time again with the id passed through:(
__________________
<!-- I can type the entire Alphabet in 2.19 seconds -->

/* (X/D)Html, Css, Javascript, Ajax, Xml (DTD), PHP, MySQL, E4X */
/* Learning C++ and German */
Smiggy is offline   Reply With Quote
Old 03-15-2008, 09:03 PM   #2 (permalink)
Senior Moderator
 
SpOrTsDuDe.Reese's Avatar
Default

If you need it to loop use a for or while loop. IF you don't know how many times you will need to loop, use while, otherwise use if.
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+
Code:
<style type="text/css"> u { text-decoration: none; } </style>
GameYin. Redesigning for DevPlooth.
SpOrTsDuDe.Reese is offline   Reply With Quote
Old 03-16-2008, 08:16 AM   #3 (permalink)
New Hunter
 

Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
Smiggy will become famous soon enoughSmiggy will become famous soon enough
Send a message via MSN to Smiggy
Default

I tried for but I think IF is the best solution.
__________________
<!-- I can type the entire Alphabet in 2.19 seconds -->

/* (X/D)Html, Css, Javascript, Ajax, Xml (DTD), PHP, MySQL, E4X */
/* Learning C++ and German */
Smiggy is offline   Reply With Quote
Old 03-16-2008, 01:19 PM   #4 (permalink)
Senior Moderator
 
SpOrTsDuDe.Reese's Avatar
Default

IF you think IF is the best solution, then you need to add an increment to keep the loop going. Personally, though I do not know why you are doing this or what for, but for or while would be my #1 pick.
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+
Code:
<style type="text/css"> u { text-decoration: none; } </style>
GameYin. Redesigning for DevPlooth.
SpOrTsDuDe.Reese is offline   Reply With Quote
Old 03-16-2008, 01:56 PM   #5 (permalink)
New Hunter
 

Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
Smiggy will become famous soon enoughSmiggy will become famous soon enough
Send a message via MSN to Smiggy
Default

It's the beginning of a drop down menu, I'm just doing a few tests before I do the proper version.
And it needs to be IF so I can place a timer on it so it works at a certain speed.
__________________
<!-- I can type the entire Alphabet in 2.19 seconds -->

/* (X/D)Html, Css, Javascript, Ajax, Xml (DTD), PHP, MySQL, E4X */
/* Learning C++ and German */
Smiggy is offline   Reply With Quote
Old 03-16-2008, 02:25 PM   #6 (permalink)
Senior Moderator
 
SpOrTsDuDe.Reese's Avatar
Default

Ah ok. You got the solution worked out or you still need the loop. Assuming you do, try...

Code:
function expand(id)
{
	var layer = document.getElementById(id).style;
	if(i != 60)
		{
			i += 1;
			layer.width = i + "%";
		}
	time = setInterval("expand(" + id + ")", 1000)
}
Without seeing your code I can't be sure whether the parameters of the setInterval is correct.
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+
Code:
<style type="text/css"> u { text-decoration: none; } </style>
GameYin. Redesigning for DevPlooth.
SpOrTsDuDe.Reese is offline   Reply With Quote
Old 03-16-2008, 04:10 PM   #7 (permalink)
New Hunter
 

Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
Smiggy will become famous soon enoughSmiggy will become famous soon enough
Send a message via MSN to Smiggy
Default

I tried it but it wouldn't past the ID through the loop:S:S

I shall have another attempt later on in the week and post it.
Many thanks.
__________________
<!-- I can type the entire Alphabet in 2.19 seconds -->

/* (X/D)Html, Css, Javascript, Ajax, Xml (DTD), PHP, MySQL, E4X */
/* Learning C++ and German */
Smiggy is offline   Reply With Quote
Old 03-16-2008, 06:03 PM   #8 (permalink)
The Dev Hunter
 
Hunter1's Avatar
 

Join Date: Mar 2007
Location: Indiana USA
Posts: 1,797
iTrader: 7 / 100%
Hunter Bux: 16,774.33
Blog Entries: 3
Hunter1 has much to be proud ofHunter1 has much to be proud ofHunter1 has much to be proud ofHunter1 has much to be proud ofHunter1 has much to be proud ofHunter1 has much to be proud ofHunter1 has much to be proud ofHunter1 has much to be proud of
Default

There are many different ways to loop your code and it looks like you are close with what your thinking is.

What type of script is this? A forum?
Hunter1 is online now   Reply With Quote
Old 03-17-2008, 04:39 AM   #9 (permalink)
New Hunter
 

Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
Smiggy will become famous soon enoughSmiggy will become famous soon enough
Send a message via MSN to Smiggy
Default

Huh?

It's for an animated drop down menu.
__________________
<!-- I can type the entire Alphabet in 2.19 seconds -->

/* (X/D)Html, Css, Javascript, Ajax, Xml (DTD), PHP, MySQL, E4X */
/* Learning C++ and German */
Smiggy is offline   Reply With Quote
Old 03-17-2008, 06:13 AM   #10 (permalink)
Senior Moderator
 
SpOrTsDuDe.Reese's Avatar
Default

Quote:
Originally Posted by Smiggy View Post
It's the beginning of a drop down menu, I'm just doing a few tests before I do the proper version.
And it needs to be IF so I can place a timer on it so it works at a certain speed.
This should answer it ;D
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+
Code:
<style type="text/css"> u { text-decoration: none; } </style>
GameYin. Redesigning for DevPlooth.
SpOrTsDuDe.Reese is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:24 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
vBCredits v1.4 Copyright ©2007, PixelFX Studios