Javascript Example

Javascript questions? ask em here.
JavaScript's official name is "ECMAScript".
Forum rules
This forum is restricted to JavaScript related questions only.

Javascript Example

Postby ag3nt42 » Wed Oct 07, 2009 10:20 pm

Below is a function written in javascript code that creates multi color letters.

Code: Select all
<html>
<script>

function MyColorFunction()
{


   var   LetterArray = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
   var FontCArray = ["red", "blue", "green", "purple", "orange", "red", "blue", "green", "purple", "orange", "red", "blue", "green", "purple", "orange", "red", "blue", "green", "purple", "orange", "red", "blue", "green", "purple", "orange", "yellow"];

   for (var x=0; x<=25; x++)
   {
      //This code writes the string to the display.
      //Notice how we plug in our variables.
      //The [] section represents an index..
      //That allows us to target each string in the arrays seperately.

      document.writeln("<font color=" + FontCArray[x] + ">" + LetterArray[x]+ "</font>");

   }

}

document.onload=MyColorFunction();

</script>
</html>
Administrator/Owner
Langauges I know
Web : XHTML, CSS, JavaScript, XML, PHP, ASP, SQL, ActionScript 3.0
Programming :Python, C#, VB, C, always learning more 8)
User avatar
ag3nt42
Site Admin
 
Posts: 38
Joined: Mon Dec 17, 2007 4:12 pm
Location: US

Return to JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest

cron