![]() |
|
|||||||
| 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 |
![]() Advertise Here |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
New Hunter
Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
![]() ![]() |
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 type the entire Alphabet in 2.19 seconds --> /* (X/D)Html, Css, Javascript, Ajax, Xml (DTD), PHP, MySQL, E4X */ /* Learning C++ and German */ |
|
|
|
|
|
#2 (permalink) |
|
Senior Moderator
|
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>
|
|
|
|
|
|
#3 (permalink) |
|
New Hunter
Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
![]() ![]() |
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 */ |
|
|
|
|
|
#4 (permalink) |
|
Senior Moderator
|
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>
|
|
|
|
|
|
#5 (permalink) |
|
New Hunter
Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
![]() ![]() |
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 */ |
|
|
|
|
|
#6 (permalink) |
|
Senior Moderator
|
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)
}
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+ Code:
<style type="text/css"> u { text-decoration: none; } </style>
|
|
|
|
|
|
#7 (permalink) |
|
New Hunter
Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
![]() ![]() |
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 */ |
|
|
|
|
|
#8 (permalink) |
|
The Dev Hunter
|
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?
__________________
Website Launch l Bid for Position l Website Advertising l phpLD Template Blogl Bid for Top l WordPress Theme Blog |
|
|
|
|
|
#9 (permalink) |
|
New Hunter
Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 86
iTrader: 0 / 0%
Hunter Bux: 5.00
![]() ![]() |
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 */ |
|
|
|
|
|
#10 (permalink) |
|
Senior Moderator
|
This should answer it ;D
__________________
+-(X)HTML, CSS, JavaScript, SEO, PHP, Flash-+ Code:
<style type="text/css"> u { text-decoration: none; } </style>
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|