moreform1.js
// JavaScript: More Forms, Example 1
// Function calculates various circular/spherical properties
//
// Copyright (c) Paul Griffiths, 2007
// Email: mail@paulgriffiths.net
function calculate(form) {
form.diameter.value = form.radius.value * 2;
form.circumference.value = Math.round(form.radius.value * 2 * Math.PI * 1000) / 1000;
form.area.value = Math.round(Math.pow(form.radius.value,2) * Math.PI * 1000) / 1000;
form.volume.value = Math.round(Math.pow(form.radius.value,3) * Math.PI * 4/3 * 1000) / 1000;
}