Welcome to WebmasterWorld Guest from 54.196.231.129

Forum Moderators: open

Message Too Old, No Replies

JavaScript

     
3:37 pm on Feb 6, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 3, 2001
posts:365
votes: 0


I know I've been posting alot lately about javascript but I'm in the process of learning it. It's getting much esier than it was at the begining of last week. Thank you all for helping me get this far.

Now, heres my question

I'm doing a statement similar to this.
function loadData(placement) {
for (i = placement; i < placement + 10; i++) { // start of for
if (i > placement) {
document.write('<tr><td bgcolor="#666666" align="right"><b><font size="2" face="Verdana, Arial, Helvetica, sans-serif">' + gather_info_date[i] + '</font></b></td></tr>');
document.write('<tr><td align="left" bgcolor="#FFFFFF"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">' + gather_info_content[i] + '</font></td></tr>');
// END
}
} // end of for
}

// What is the equivalent of ENDing a script in Javascript?

I'm trying to tell it that if i is greater then placement, stop printing the document.write. I dont know if I'm doing it right or not but most of the code is coming along just great! :)

Thanks

6:15 pm on Feb 6, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 0


to jump out of a loop (such as a for loop) use:

break;

6:24 pm on Feb 6, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 10, 2001
posts:793
votes: 0


Also worth mentioning here that if you're in a function and you want to leave the function at certain point - i.e. not process the remaining instructions you can return false;.