How To Program - Chapter2 - The Colour
How To Program - Chapter2 - The Colour
Here is a look at the script. See if you can trace how it works.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -
function changecolor(code) {
document.bgColor=code
}
</HEAD>
<BODY>
<form>
<input type="button" name="Button1" value="RED" onclick="changecolor('red')">
</form>
</BODY>
</HTML>
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.