question about cycling through a series of functions

J

Julia Briggs

How would I create another function that would cycle sequentially
through each of these? like 1..,2..,3,..4,..1,..etc..

function1() { something }
function2() { something }
function3() { something }
function4() { something }
 
T

The Mighty Krell

Julia Briggs said:
How would I create another function that would cycle sequentially
through each of these? like 1..,2..,3,..4,..1,..etc..

function1() { something }
function2() { something }
function3() { something }
function4() { something }


function5()
{
loop
call the other functions
end loop
}


MK
 
I

Ivo

"Julia Briggs" wrote
<snip>
Using eval():

function fun1() { alert( 'Greetings from function ' + 1); }
function fun2() { alert( 'Hello from function ' + 2); }
function fun3() { alert( 'Hi from function ' + 3); }

function go() {
for( var i=1; i<4; i++ ) {
eval( 'fun' + i + '()' );
}
}
go();

Loop through function go() as often as you like.
hth
 
T

The Mighty Krell

Ivo said:
<snip>
Using eval():

function fun1() { alert( 'Greetings from function ' + 1); }
function fun2() { alert( 'Hello from function ' + 2); }
function fun3() { alert( 'Hi from function ' + 3); }

function go() {
for( var i=1; i<4; i++ ) {
eval( 'fun' + i + '()' );
}
}
go();

Loop through function go() as often as you like.
hth


Why in the world would you use eval for something this trivial?
 
R

Randy Webb

The said:
Why in the world would you use eval for something this trivial?

Not that its "trivial". But why use it when its not needed?


function go(){
for (var i=1; i<4; i++){
window['fun'+i]()
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top