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

sending an array as an argument for a function

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I recently made some dhtml with javascript. I made a function which loads the layer names and the number of layers into an array. This function then calls another one with this code -= openit(layers[length],length); =-
This executes perfectly b/ with the openit function i keep getting an error when i write this -=>
function openit(layers[length],length) {

The error is on the layers[length] entry. I tried only placing "layers" in this area b/ by doing so this only turned the array into a scalar. layers=Home3. and layers[1]=undefined, when layer[1] should = Home1...this should of had a value. Why is this error occuring?
 
I am not sure but maybe it's because the length is the number of elements in the array - but they are numbered:
0 --> length-1
try using lenght-1,
because layers[length-1] is the last layer in the array.
-BB "Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top