Javascript

by

There are several ways to call a javascript function from an HTML form to process user-supplied values and then return the results to the user including onclick, onchange, and onkeyup. Using a simple form that takes an input value and returns the square of this value to the user, I demonstrate these three methods below.

by

The HTML and javascript code below demonstrates how to use a value entered into an HTML form to perform a calculation and return the result. This example simply squares the input value. Some simple checking is performed to ensure that the input value is a number. The following form demonstrates the code in action.