Subject: For Loop Not incrementing
Posted By: donrafeal7 Post Date: 10/23/2006 6:05:31 PM
Why is my for loop not incrementing?

I declare the variable i to equal 2, and for testing I have an aleart box popup with the value at i, which is equal to 2, then after the for loop I have another alert box which is equal to i, which should be 4 but is 2 instead.  This means my for loop is not incrementing.  What did I do wrong?

        var i = 2;
        
            alert("Test: " + i);
        for (i = 2; i > 4; i++);
        {
            TFor="Tab" + i;
            BFor="Body" + i;
                       //i = i + 1;
        }
        alert("Test: " + i);

thanks,
Donrafeal7

Reply By: kaos_frack Reply Date: 10/24/2006 12:24:24 AM
the problem is on this line:

for (i = 2; i > 4; i++);

i'm sure you wanted to write
i < 4
instead of
i > 4

and also you mustn't have a semicolon after the closing brace

Go to topic 51354

Return to index page 141
Return to index page 140
Return to index page 139
Return to index page 138
Return to index page 137
Return to index page 136
Return to index page 135
Return to index page 134
Return to index page 133
Return to index page 132