Home
 
 
Search:  
C C++ Perl PHP Python HTML ShellScripts
 
 
  Coding Books
  Tutorials
  Search Code
  Browse Code
  Link to Us
  Site News
  Contact Metalshell
 
 
 
  Submit Code   Statistics
 



HTML 4 Bible (with CD-ROM)    (ISBN: 0764534734)


 

 List Price: $49.99
 Our Price: $34.99
 Used Price: $19.00

 Release Date: 15 January, 2000
 Manufacturer: John Wiley & Sons (Paperback)
 Sales Rank: 63,247

 Author: Bryan Pfaffenberger, Bill Karrow









More Info

 Javascript While Loop 2002-09-14 18:39:45
  html 
Category: source:html:javascript
Description: Example on how to use the while statement in a javascript.
Platform: all
Author: mind
Viewed: 21072
Rating: 3.6/5 (31 votes)
If you have any questions about this piece of code or still need help, try posting your question on the forum.

 

Printable Version
while.js
<!-- while.js - mind (mind@metalshell.com) -->

<!-- this shows a basic example of how to use -->
<!-- the while statement in javascripting -->
<!-- http://www.metalshell.com -->

<!-- put this code into the <head> section of your html document. -->

<!-- start our javascript -->
<script language=JavaScript>
        // define i as a integer of 0
        var i = 0;

        // define max as a integer of 10
        var max = 10;

        // define message a string of: This is..
        var message = "This is our message";

        // create our function
        function printText()
        {
                // while (condition) { statements; }

                // start our while loop
                while (i < max)
                {
                        // increase i with each loop
                        i++;

                        // print our message
                        document.write('<font>' + message + '</font><br>');
                }
        }

        // never ending while loop: while (1) { statements; }

        // end of our javascript
</script>

<!-- place this code anywhere on your html document (example) -->

<!-- align our link below -->
<div align=center>
        <!-- make a link that points to our js function printText() -->
        <a href="javascript: printText();">Click Here!</a>
</div>
Rate this code:
(Not Helpful)  (Very Helpful) 

 
 
   Developer.*  
   Blue Parrots  
   Technipal  
   Defy Magazine  
   Code Project  
   Prog. Heaven  


Got Money?