Web Teacher Software
web database
Javacript 
Tutorial
CGI tutorial
web 
database consulting
web database training
contact us about web 
database software
press
Hosted Database Solutions
webteacher home
Web Teacher Consulting

javascript tutorial graphic


Webteacher Software now offers

function changecolor(code) {
document.bgColor=code
}


This page is an excellent example of one function being used by several buttons in the same document. Our function is called changecolor(code). It has only one line:
document.bgColor=code.

You probably guessed that bgColor stands for background color.
If I type document.bgColor="red" the background will turn red.

By writing the command document.bgColor=code I am allowing myself to define the variable code as any color I want.

Later, in the form. I define a button with the command:
onClick="changecolor('green')"

onClick="changecolor('green')" is telling the program 2 things:

  1. Run the funtion named changecolor(code).
  2. code='green'
Next Chapter

Home | WebData - Web Database Software | Javascript | CGI | Consulting | Map Builder | Contact Us | The Press Room