Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 23rd, 2006, 06:05 PM
Authorized User
 
Join Date: Oct 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default For Loop Not incrementing

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

 
Old October 24th, 2006, 12:24 AM
Authorized User
 
Join Date: May 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kaos_frack
Default

the problem is on this line:
Code:
for (i = 2; i > 4; i++);
i'm sure you wanted to write
Code:
i < 4
instead of
Code:
i > 4
and also you mustn't have a semicolon after the closing brace





Similar Threads
Thread Thread Starter Forum Replies Last Post
Incrementing attribute value Pankaj C XSLT 4 October 31st, 2007 05:40 AM
reading and incrementing a value phantom3008 ASP.NET 1.0 and 1.1 Basics 0 April 18th, 2007 10:29 AM
XSL Loop and incrementing a variable 2007-03-29 XSLT 8 March 30th, 2007 10:41 AM
Incrementing a value within a template Tre XSLT 1 March 21st, 2007 09:31 AM
incrementing javascript loop use i++ or ++i crmpicco Javascript How-To 4 May 11th, 2006 01:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.