See I want to make a calculator that calculates first 80% of the intial value A, and takes that result (B), and takes 10% of B to make C my end result. This is the script that I have:
<script type = "text/javascript">
function calcPercent()
{
//Comments in code have these double slashes.
//They're just comments for programmers, they don't
//change anything in the program.
//When the user clicks the button this function, calcPercent, is called.
//Get input value
var startVal = document.myForm.a.value;
//Calculate the percentages
var first = startVal * .8;
var second = first * .1;
//Round the number. Otherwise
//you can get a lot of decimals.
var roundFirst = Math.round(first * 100)/100
var roundSecond = Math.round(second * 100)/100
//Write results to the textboxes
document.myForm.b.value = roundFirst;
document.myForm.c.value = roundSecond;
}
</script>
How would I make the html form fit with that?
Edited by Roger, 25 November 2010 - 02:16 PM.
added code tag


Sign In
Create Account

Back to top









