Good day!

Theres a programmer help me to display and subract the total earn and total deduction, the only problem now is when I add data in total earn it did not add in Over all total.. the only good happen is when I add deductions it take it takes effect or subtract in over all total..

Like for example I add total earn from 1000 i add 20 the total earn become 1020 but the overall total still 100 but when i add also deduction from 100 I add 10 the overall total become 910 which is correct. I only want is when the total earn was change also the overall total will also change..

Thank you

here is the revise code:
Code:
<script type="text/javascript">
var tot;
function autocalearn(oText)
{
if (isNaN(oText.value)) //filter input
{
alert('Numbers only!');
oText.value = '';
}
var field, val, oForm = oText.form, TotEarn = a = 0;
for (a; a < arguments.length; ++a) //loop through text elements
{
field = arguments[a];
val = parseFloat(field.value); //get value
if (!isNaN(val)) //number?
{
TotEarn += val; //accumulate
}
}

tot=Number(TotEarn) + Number(document.getElementById('Amount').value);
oForm.TotEarn.value = tot.toFixed(2);

 
}

</script>


<script type="text/javascript">

function autocalded(oText)
{
if (isNaN(oText.value)) //filter input
{
alert('Numbers only!');
oText.value = '';
}
var field, val, oForm = oText.form, TotalDed = a = 0;
for (a; a < arguments.length; ++a) //loop through text elements
{
field = arguments[a];
val = parseFloat(field.value); //get value
if (!isNaN(val)) //number?
{
TotalDed += val; //accumulate
}
}


var totded=Number(TotalDed) + Number(document.getElementById('Deductions').value);
oForm.TotalDed.value = totded.toFixed(2);
var overallTotal = tot - totded;

oForm.TakeHomePay.value = overallTotal.toFixed(2); 
}

</script>

<div class="income">
<fieldset>
	<legend>EARNINGS</legend>
		<p>
		<label for = "Rate" class = "LLabel">Rate:</label>
		<input name= "Rate" class = "LField" type="text" maxlength="12" tabindex="0" size="12" value="{$Rate}" readonly="readonly"/>
		
		<label for = "Hours" class = "LLabel">&nbsp;Hours:</label>
		<input name= "Hours" class = "LField" type="text" maxlength="12" tabindex="0" size="12"  value="{$Hours}" readonly="readonly"/>
    	</p>
		<p>
		<label for = "Amount" class = "LLabelTot">&nbsp;&nbsp;<b>Amount:</b></label>
		<input name= "Amount" id="Amount" class = "LFieldTot" type="text" maxlength="12" tabindex="0" size="12" value="{$Amount}" readonly="readonly"/>
		</p>
	<div class="OT">
	<fieldset>
		<legend>OTHERS</legend>
        <label class="p">Hours</label><label> Amount</label>
		<p>
		<label for = "RegOT" class = "LLabelOT">Regular Overtime:</label>
		    <input name= "RegOTHrs" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
		    <input name= "RegOTAmt" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,SunSpecHolAmt,SunSpecHolOtAmt, RegHolAmt, RegHolOtAmt, HolLeaveAmt, NightPremAmt, MealAllowAmt, COLAAmt, ThirteenMonAmt)" value="0.00" />
		<label for = "SunSpecHol" class = "LLabelOT">Sun/Spec Holiday:</label>
		    <input name= "SunSpecHolHrs"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
		    <input name= "SunSpecHolAmt"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolOtAmt, RegHolAmt, RegHolOtAmt, HolLeaveAmt, NightPremAmt, MealAllowAmt, COLAAmt, ThirteenMonAmt)" value="0.00" />
		<label for = "SunSpecHolOt" class = "LLabelOT">Sun/Spec Hol. OT:</label>
		    <input name= "SunSpecHolOtHrs"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
		    <input name= "SunSpecHolOtAmt"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, RegHolAmt, RegHolOtAmt, HolLeaveAmt, NightPremAmt, MealAllowAmt, COLAAmt, ThirteenMonAmt)"  value="0.00" />
        <label for = "RegHol" class = "LLabelOT">Reg. Holiday:</label> 
            <input name= "RegHolHrs"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
            <input name= "RegHolAmt"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, SunSpecHolOtAmt, RegHolOtAmt, HolLeaveAmt, NightPremAmt, MealAllowAmt, COLAAmt, ThirteenMonAmt)" value="0.00" />
		<label for = "RegHolOt" class = "LLabelOT">Reg. Holiday OT:</label> 
            <input name= "RegHolOtHrs" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
            <input name= "RegHolOtAmt" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, SunSpecHolOtAmt, RegHolAmt, HolLeaveAmt, NightPremAmt, MealAllowAmt, COLAAmt, ThirteenMonAmt)" value="0.00"/>
        <label for = "HolLeave" class = "LLabelOT">Holiday/Leave:</label> 
            <input name= "HolLeaveHrs" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
            <input name= "HolLeaveAmt" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, SunSpecHolOtAmt, RegHolAmt, RegHolOtAmt, NightPremAmt, MealAllowAmt, COLAAmt, ThirteenMonAmt)" value="0.00"/>
        <label for = "NightPrem" class = "LLabelOT">Night Premium:</label> 
            <input name= "NightPremHrs" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
            <input name= "NightPremAmt" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, SunSpecHolOtAmt, RegHolAmt, RegHolOtAmt, HolLeaveAmt, MealAllowAmt, COLAAmt, ThirteenMonAmt)" value="0.00"/>
        <label for = "MealAllow" class = "LLabelOT">Meal Allowance:</label> 
            <input name= "MealAllowHrs"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
            <input name= "MealAllowAmt"  class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, SunSpecHolOtAmt, RegHolAmt, RegHolOtAmt, HolLeaveAmt, NightPremAmt, COLAAmt, ThirteenMonAmt)" value="0.00"/>
        <label for = "COLA" class = "LLabelOT">COLA (P14 Allow):</label> 
            <input name= "COLAHrs" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
            <input name= "COLAAmt" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, SunSpecHolOtAmt, RegHolAmt, RegHolOtAmt, HolLeaveAmt, NightPremAmt, MealAllowAmt, ThirteenMonAmt)" value="0.00"/>
        <label for = "ThirteenMon" class = "LLabelOT">13th Month:</label> 
            <input name= "ThirteenMonHrs" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" value="0.00"/>
            <input name= "ThirteenMonAmt" class = "LFieldOT" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalearn(this,RegOTAmt,SunSpecHolAmt, SunSpecHolOtAmt, RegHolAmt, RegHolOtAmt, HolLeaveAmt, NightPremAmt, MealAllowAmt, COLAAmt)" value="0.00"/> 
        <label name= "TotEarn" class="LLabelTotEarn"><b>Total Earnings:</b></label><br/>
            <input name="TotEarn" class="LFieldOT" type="text" maxlength="12" tabindex="0" size="10" readonly="readonly" value="{$TotEarn}">       
        </p>                               	
	</fieldset>
</fieldset>
</div> 
</div>

<div class="deductions">
<fieldset>
<legend>DEDUCTIONS</legend>
	<p>
	<label for = "SSS" class = "LLabelDed">SSS:</label>
		<input name= "SSS" class = "LFieldDed" type="text" maxlength="12" tabindex="0" size="12" value="{$SSS}" readonly="readonly" />
	<label for = "TAX" class = "LLabelDed">&nbsp;TAX:</label>
		<input name= "TAX" id="TAX" class = "LFieldDed" type="text" maxlength="12" tabindex="0" size="12" value="{$TAX}" readonly="readonly" />
	<label for = "PCHL" class = "LLabelDed1">PCHL:</label>
		<input name= "PCHL" id="PCHL" class = "LFieldDed1" type="text" maxlength="12" tabindex="0" size="12" value="{$PCHL}" readonly="readonly" />
	<label for = "HDMF" class = "LLabelDed2">&nbsp;HDMF:</label>
		<input name= "HDMF" id="HDMF" class = "LFieldDed2" type="text" maxlength="12" tabindex="0" size="12" value="{$HDMF}" readonly="readonly" />
    <label for = "Deductions" class = "LLabelPrimDed"><b>Deductions:</b></label>
        <input name= "Deductions" id="Deductions" class = "LFieldPrimDed" type="text" maxlength="12" tabindex="0" size="12" value="{$Deductions}" readonly="readonly" />
    </p>  
    
<div class="loan">
<fieldset>
<legend>LOANS</legend>
<label>Amount</label>
<p>
<label for="SSSLoan" class="LLabelLoan">SSS Loan:</label>
    <input name= "SSSLoan" id="SSSLoan" class = "LFieldLoan" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, HDMFLoan, Fund, HospLoan, BurialSep, TaxAjt, CashAdvance, AdvancesShirt, AdvancesMed, AdvancesOthers)" value="0.00" />
<label for="HDMFLoan" class="LLabelLoan1">&nbsp;HDMF Loan:</label>
    <input name= "HDMFLoan" id="HDMFLoan" class = "LFieldLoan1" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, Fund, HospLoan, BurialSep, TaxAjt, CashAdvance, AdvancesShirt, AdvancesMed, AdvancesOthers)" value="0.00" />
<label for="Fund" class="LLabelLoan">Union Dues/Trust Fund:</label>
    <input name= "Fund" id="Fund" class = "LFieldLoan" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, HospLoan, BurialSep, TaxAjt, CashAdvance, AdvancesShirt, AdvancesMed, AdvancesOthers)" value="0.00" />
<label for="HospLoan" class="LLabelLoan1">&nbsp;Hosp Loan:</label>
    <input name= "HospLoan" id="HospLoan" class = "LFieldLoan1" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, Fund, BurialSep, TaxAjt, CashAdvance, AdvancesShirt, AdvancesMed, AdvancesOthers)" value="0.00" />           
</p>
</fieldset>

<div>
<fieldset>
<legend>OTHERS</legend>
<p>
<label for="BurialSep" class="LLabelLoan">Burial/Separation Cont:</label>
    <input name= "BurialSep" id="BurialSep" class = "LFieldLoan" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, Fund, HospLoan, TaxAjt, CashAdvance, AdvancesShirt, AdvancesMed, AdvancesOthers)" value="0.00" />
<label for="TaxAjt" class="LLabelLoan1">&nbsp;Tax Ajt:</label>
    <input name= "TaxAjt" id="TaxAjt" class = "LFieldLoan1" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, Fund, HospLoan, BurialSep, CashAdvance, AdvancesShirt, AdvancesMed, AdvancesOthers)" value="0.00" />
<label for="CashAdvance" class="LLabelLoan">Cash Advance:</label>
    <input name= "CashAdvance" id="CashAdvance" class = "LFieldLoan" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, Fund, HospLoan, BurialSep, TaxAjt, AdvancesShirt, AdvancesMed, AdvancesOthers)" value="0.00" />
<label for="AdvancesShirt" class="LLabelLoan1">&nbsp;Advances (Shirt):</label>
    <input name= "AdvancesShirt" id="AdvancesShirt" class = "LFieldLoan1" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, Fund, HospLoan, BurialSep, TaxAjt, CashAdvance, AdvancesMed, AdvancesOthers)" value="0.00" />
<label for="AdvancesMed" class="LLabelLoan">Advances (Medical):</label>
    <input name= "AdvancesMed" id="AdvancesMed" class = "LFieldLoan" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, Fund, HospLoan, BurialSep, TaxAjt, CashAdvance, AdvancesShirt, AdvancesOthers)" value="0.00" />
<label for="AdvancesOthers" class="LLabelLoan1">&nbsp;Advances (Other):</label>
    <input name= "AdvancesOthers" id="AdvancesOthers" class = "LFieldLoan1" type="text" maxlength="10" tabindex="0" size="10" onkeyup="return autocalded(this, SSSLoan, HDMFLoan, Fund, HospLoan, BurialSep, TaxAjt, CashAdvance, AdvancesShirt, AdvancesMed)" value="0.00" />    
<label for="TotalDeductions" class="LLabelLoan">&nbsp;<b>Total Deductions:</b></label>
    <input name= "TotalDed" class = "LFieldLoan" type="text" maxlength="10" tabindex="0" size="10" value="{$TotalDed}" />
</p>
</fieldset>    
</fieldset>
</div>
</div>
</div>
<div>
<label for="TakeHomePay" class="LLabelTakeHomePay"><b>Take Home Pay:</b></label>
    <input name= "TakeHomePay" id="overallTotal" class = "LFieldLoan" type="text" maxlength="20" tabindex="0" size="10" value="{$THP}" />
    &nbsp;<input type="button" name="save" value="SAVE" onclick="savePay()">
</div>
Thank you