In my form I have five text boxes
-amount
-tax
-total
-paid
-balance
when user enters the amount it should automatically calculate tax by
multiplying amount by .07 and shows result in tax input box, the total box
shows amount + tax value and when user enters paid value it automatically
calculates and displays balance in balance field. I hope I m clear.
Thank you
dempster - 31 Dec 2005 00:42 GMT
So what problem are you having? You can have an onChange event handler in the
price field and a function that calculates the tax and total price. See
attached code sampel.
-Paul
<SCRIPT LANGUAGE="JavaScript">
function addTax(amt) {
document.sale.Tax.value = parseFloat(amt.value) * .07;
document.sale.withTax.value = parseFloat(document.sale.Tax.value) +
parseFloat(amt.value);
}
</SCRIPT>
<FORM ACTION="" NAME="sale">
Price: <INPUT TYPE="text" NAME="price" SIZE="10" ONCHANGE="addTax(this);"><BR>
Tax: <INPUT TYPE="text" NAME="Tax" SIZE="10"><BR>
Total: <INPUT TYPE="text" NAME="withTax" SIZE="10"><BR>
</FORM>