Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Getting Started / December 2005



Tip: Looking for answers? Try searching our database.

Javascript Onchange

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DDhillon - 30 Dec 2005 23:58 GMT
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>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.