change
for(i=0;i<b.value;i++) {
to
for(var i=0;i<b.value;i++) {
javascript is treating "i" as a global var so when you call itself, global
"i" gets changed which will bugger up your loop - I've done this soooo many
times and spent toooo many hours trying to debug, just to find I forgot to
declare a var as local!!
-----Original Message-----
From: Alex Elderson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 10, 2002 10:44 PM
To: [EMAIL PROTECTED]
Subject: [PHP] global/local var in a function
Hi,
I have a little problem with a function. It calls him self and the var i is
lost! after the call!
can anybody help me?
(it's javascript)
function change_check_all(tree_item) {
a = document.all[tree_item + "_check"];
b = document.all[tree_item + "_count"];
for(i=0;i<b.value;i++) {
if (a.value=="off") {
change_check_to(tree_item + "_" + i, 0);
} else {
change_check_to(tree_item + "_" + i, 1);
}
change_check_all(tree_item + "_" + i, i);
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]