Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Form Field Deduction 1

Status
Not open for further replies.

pastorandy

IS-IT--Management
Nov 2, 2006
84
GB
I have two form fields and I want to be able to subtract the value from one. What I currently have doesn't work.

I haven't written a javascript function before but this is what I have:
Code:
<script language="JavaScript">
function deduct() 
{
document.form1.payment_amount.value = --document.form1.payment_deduction.value;
}
</script>
I was hoping that whatever value was in payment_deduction would get subtracted from payment amount.

I have the two form fields and a button to trigger the function:

Code:
<input type="button" name="btnSub" onClick="javascript:deduct();">

Could someone point me in the right direction?
 
As a start, but you have to make a lot of assumptions on the user's entries.
[tt]document.form1.payment_amount.value-=document.form1.payment_deduction.value;[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top