RE: [PHP] global/local var in a function
| From: | Niklas Lampén | Date: | Thu, 10 Jan 2002 11:59:35 +0000 |
| Subject: | RE: [PHP] global/local var in a function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-80014@lists.php.net to get a copy of this message | ||
This is because it creates a new "thread", atleast I think it so. Use
global variables to prevent this from happening:
i = 0;
function change_check_all(tree_item) {
a = document.all[tree_item + "_check"];
b = document.all[tree_item + "_count"];
// changed the line below
for(i = $GLOBALS[i];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);
}
}
Niklas
-----Original Message-----
From: Alex Elderson [mailto:alex@netflex.nl]
Sent: 10. tammikuuta 2002 13:44
To: php-general@lists.php.net
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: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net To
contact the list administrators, e-mail: php-list-admin@lists.php.net