A copy of the JavaScript functions in the head element:
// sample-1-getElementById-functions.js
// This sample uses getElementById() to find the input areas
// Reset values onload of the body
function loaded()
{
var input_area = document.getElementById("change-input");
input_area.value = "";
var result_area = document.getElementById("result");
result_area.value = "";
}
// input change event handler
// twice the number in the input area is put in the result area
function changeInput()
{
var input_area = document.getElementById("change-input");
var result_area = document.getElementById("result");
var input_value = parseFloat(input_area.value);
if ( isNaN(input_value ) )
{
result_area.value = "";
}
else
{
result_area.value = 2 * input_value;
}
}