Buttons
With buttons, you can do an assortment of things, including changing the background color. However, buttons are one dimensional. All you can do is click them so the only event handler you can use is the onClick event handler.
Background Colors!
The first thing to learn is how to make a button.
<form>
<input type="button" value="words_on_the_button">
</form>
To change the color of the background, add this code inside the button tag.
onClick="document.bgColor='any color'"
This is just like the onMouseOver event handler. This one says, onMouseOver, the document's background color becomes the color you specify.
If you put buttons to change the background on your page, make sure that you have a button to go back to the original color.
The main colors that you would want to use you can just type the name. However, some colors you need to type the red, blue, yellow #'s of. I will have a list of all the colors and there red, blue, yellow #'s.
Here are a bunch of buttons which will change the background color.
Other Things!
You can do many other things with the onClick. You could make an alert, call a function, have a number printed on the screen, provide a link, etc.
Now that you understand onClick, go to onChange/onBlur event handlers.
Back Homepage Event Handlers Next