global/local var in a function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


global/local var in a function

Alex_EldersonAlex_Elderson Posts: 104Member

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?

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);


  • FirestormFirestorm Posts: 162Member
    Well I can help you but I'd like to give you a general tipp when writing functions:
    It is very hard to understand your source code because when you look at it the first time you can't see which subfunction is where or where it start or ends.
    do that and that

    Also when posting a code like this some comments would help in understanding it!

    [email protected]

Sign In or Register to comment.