also @ TechSpot: Digital game purchases: do we really "own" them?
Welcome to the TechSpot OpenBoards. Please read the FAQ if you have any questions. Sign up or Login to participate.

Go Back   TechSpot OpenBoards > Software > Windows OS

Begin your free trial now Pay-as-you-go options starting at $10/user/month

Does anybody here know javascript? Odd function problem

Thread Tools Search this Thread
  #1  
Old 02-02-2006
Vigilante's Avatar
TechSpot Paladin
 
Location: Arizona, USA
Member since: Dec 2004, 2,120 posts
Does anybody here know javascript? Odd function problem

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:

Quote:
<script>
function test() {
var somevar;
var somevar2;
//other assignments

for ( the main for loop ) {

// all kinda stuff in for loop

}

// NOTHING HERE EXECUTES!!

}
</script>
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  
Old 02-03-2006
Newcomer, in training
 
Location: Australia
Member since: Jan 2006, 16 posts
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  
Old 02-03-2006
Vigilante's Avatar
TechSpot Paladin
 
Location: Arizona, USA
Member since: Dec 2004, 2,120 posts
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.
Closed Thread

Similar Topics
Topic Replies Forum
Problem with IF function 0 Windows OS
Javascript problem? 13 Virus and Malware Removal
Problem with Dell Keyboard Function 0 Device Drivers
Problem with JavaScript/Flash 8 1 Software Apps
Thumbnail (javascript) problem - help plz! 0 Windows OS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
All times are GMT -4. The time now is 02:46 PM.