in the function initDog, imgSetNum = Dogs.indexOf(dog) always return -1 (not found). I verified that the "dog" value is correctly set to a dog name in the Dogs array.
How do you call initDog ? with intDog() or with initDog("") ?
if (!dog) { dog='Raven'; } could be better as if(dog === "") {dog='Raven';} to work with both syntaxes...
ImgMax and imgSetNum are now local variable in the function. They have to be defined with a var imgMax,imgSetNum; outside to be global variables !
The code works perfectly for me. The error is outside the code you posted I believe.
Originally Posted by 007Julien
ImgMax and imgSetNum are now local variable in the function. They have to be defined with a var imgMax,imgSetNum; outside to be global variables !
That's not true. You have to use the 'var' keyword to make a local variable, or else it will be global by default. (Variables should be declared with var somewhere though for clarity and to give it a better closure than the global scope.)
The var ingSetNum and imgMax are defined locally.
The value of 'dog' is passed using php:
onload="initDog(<?php echo "'".$_GET['dogname']."'"?>);imgNum=0;nextImg()">
I verified that 'dog' really contains the dog name listed in the array Dogs.
Bookmarks