Does anybody here know javascript? Odd function problem

By Vigilante
Feb 2, 2006
  1. Hey, I usually have other forums for programming, but since I like it here, I figured I'd give my fellow members a shot at it. Let me summarize my code, see if you can tell me why I'm having the issue. Here is a mock up, simplistic java function:

    Can anybody tell me why I cannot execute any code after the for loop, inside the function? Or why that might be?
    Note that in the for loop, I use NO break or continue statements. In the for loop I have a while loop and one IF statement. That's it. But when the FOR loop ends, I can't do anything else in code. What's up with that?
    I know the for loop and sub code works just fine, as I've monitored it and the output is perfect. But when the loop comes to an end, apparently so does all other code in the function.

    Any ideas?
  2. Matt_2006

    Matt_2006 TS Rookie

    Your code seems fine, but is anything actually calling the function?

    Is this code in the HEAD or BODY of the page? It doesn't matter too much, but I personally put it in the head. If it is in the body and there are no parameters, you don't really need the function test() { and last }. It should just execute. But if you prefer to have that, call the function. Easiest way would be just before the close script tag, put on a new line test(); unless you want it called at a specific point.

    Hope that helps :)
  3. Vigilante

    Vigilante TechSpot Paladin Topic Starter Posts: 1,666

    I finally found the problem and it had to do with an inner WHILE loop, my counter was going out of bounds and throwing an error on the while condition check.

    IE actually helped with this, as it gives you the java error, which I never noticed because I was using Avant.

    Oh well, the issue is resolved. Thanks for the thought.
Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...