JavaScript Source Code 3000: Calculators: Percent of Increase
Percent of Increase
Enter two numbers and JavaScript will help you determine the percent of increase. This is a perfectly simple example of using a JavaScript return function. Check it out!
Enter the two numbers to determine the percent of increase: to
JavaScript Source Code 3000: Calculators: Percent of Increase Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL PERCENT OF INCREASE:
1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript"> <!-- Original: Joey Mornin (jmornin@gateway.net) --> <!-- Modified with permission by Ronnie T. Moore -->
<! > <! >
<!-- Begin function findIncrease(form) { var num1 = form.num1.value; var num2 = form.num2.value; return ((num2 - num1) / num1 * 100 + "%"); } // End --> </script> </HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<center> <form name=increaseform> Enter the two numbers to determine the percent of increase:<p> <input type=text name=num1 size=4> to <input type=text name=num2 size=4> <input type=button value="Solve" onClick="this.form.answer.value = findIncrease(this.form);"><p> The percentage of increase is <input type=text name=answer size=6> </form> </center>