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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic function names 1

Status
Not open for further replies.

dle46163

IS-IT--Management
Joined
Jul 9, 2004
Messages
81
Location
US
Hi All!

I'm working on a javascript which loops a set number of times. When it loops I want to generate some functions with dynamic names that I can call later in my code. Though, I'm having a hard time getting this to work. Here's the code within my loop to generate my funtions:

slide_number=slide_number+1;

function this["slide"+slide_number](){
alert ('yo');
}

Later I would like to call on the functions slide1(), slide2(), etc... but the code pukes on the above before I can even call the functions. Any thoughts on syntax here? Thanks!





 
How about something like:
Code:
window["slide"+slide_number] = function (){
  alert ('yo');
  }

Lee
 
Worked!!! Thank you soooo much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top