Inline Example Page

Using radio buttons in this page it will be easy to show you how to write inline scripts. Take the example below; by clicking on one of the buttons you can change the background color of the page. Fortunately this script also works in netscape. Give it a try.

red orange green turquoise blue white

Here is how I set up the form with the radio buttons containing the javascript

<form>
<input type="radio" onClick="document.bgColor = 'red'">red
<input type="radio" onClick="document.bgColor = 'orange'">orange
<input type="radio" onClick="document.bgColor = 'green'">green
<input type="radio" onClick="document.bgColor = 'turquoise'">turquoise
<input type="radio" onClick="document.bgColor = 'blue'">blue
<input type="radio" onClick="document.bgColor = 'white'">white
</form>

Notice the use of the double quotes to enclose the entire onClick event and the use of the single quotes to enclose just the color wanted. Make sure that the single quotes are nested (placed within) the double quotes. If they are left off or used improperly the script will bomb in IE or netscape browsers... possibly both.


Hope that this helps you...

Author: Joseph Raymond

28th of March, 2001