Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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!


Sign In or Register to comment.