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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required error 1

Status
Not open for further replies.

haneen97

Programmer
Dec 10, 2002
280
US
Hi I have these JS functions:

If the CalculateVlaues() function is triggered, I get an Object required error on the closed prent on top of the function name. Aand if the Reset() function is called I get the same error on the close prent on top of function name too. I verified the variables and field names in the functions, they seem to be all valied.

Pleas help.

function AdjustValues(which,txtValue)
{
var Qty=which.value;
var PrevTotal=document.getElementById('txtTotal').value * 1;
var PrevSubTotal=document.getElementById('txtSubTotal').value * 1;
var ItemSubTotal=document.getElementById(txtValue+'Total').value * 1;
var PrevQtyOnHand=document.getElementById(txtValue+'QtyOnHand').value * 1;
var unitprice=document.getElementById(txtValue+'UPrice').value * 1;
var NewQtyOnHand=PrevQtyOnHand + Qty;

document.getElementById(txtValue+'QtyOnHand').value = NewQtyOnHand;
document.getElementById(txtValue+'Total').value = 0;
document.getElementById('txtSubTotal').value = PrevSubTotal - ItemSubTotal;
document.getElementById('txtTotal').value = PrevTotal - ItemSubTotal;
return (true);
}

function CalculateVlaues()
{
var CurrTotal=document.getElementById('txtTotal').value * 1;
var Discount = 1-((document.getElementById('txtDiscount').value * 1)/100);
var ExtraCharges = parseInt(document.getElementById('txtExtraCharge').value * 1);
var DiscountAmt = (CurrTotal * Discount);
var NewTotal=(CurrTotal - DiscountAmt) + ExtraCharges;
document.getElementById('txtTotal').value = NewTotal;
return (true);
}

function Reset()
{
var CurrTotal=document.getElementById('txtTotal').value * 1;
var Discount = 1-((document.getElementById('txtDiscount').value * 1)/100);
var ExtraCharges = parseInt(document.getElementById('txtExtraCharge').value *1);
var NewTotal=(CurrTotal - ExtraCharges)/ Discount;
document.getElementById('txtTotal').value = NewTotal;
return (true);
}

Thanks.

Mo
 

Are you calling "CalculateVlaues" or "CalculateValues" ? Make sure you are spelling the function name correctly (or rather, incorrectly ;o) when calling it.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
It was spelled wrong in both places. I don't think that is the problem.

Mo
 

Can you show the calling code?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
This is the calling code. Sorry don't have a link. It is a local application.

<td width="20%"><form action="" method="post" name="frmCalc" id="frmCalc">
<div align="center">
<p><font size="2" face="Arial, Helvetica, sans-serif"><strong>Charges</strong></font></p>
<p align="left"><strong><font size="2" face="Arial, Helvetica, sans-serif">Sub
Total:
<input name="txtSubTotal" type="text" id="txtSubTotal" style="width:50px;" value="<% Response.Write ("0") %>">
</font></strong></p>
<p align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Discount
%: </strong>
<input name="txtDiscount" type="text" id="txtDiscount" style="width:50px;" value="<% Response.Write ("0") %>">
</font></p>
<p align="left"> <font size="2" face="Arial, Helvetica, sans-serif"><strong>Extra
Charges:
<input name="txtExtraCharges" type="text" id="txtExtraCharges" style="width:50px;" value="<% Response.Write ("0") %>">
</strong></font></p>
<p align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Total
Cost:
<input name="txtTotal" type="text" id="txtTotal" style="width:70px;" value="<% Response.Write ("0") %>">
</strong></font></p>
<p align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Amount
Paid:
<input name="txtAmtPaid" type="text" id="txtAmtPaid" style="width:70px;" value="<% Response.Write ("0") %>">
</strong></font></p>
<p align="left"><font size="2" face="Arial, Helvetica, sans-serif"><strong>
Unpaid:
<input name="txtUnpaid" type="text" id="txtUnpaid" style="width:70px;" value="<% Response.Write ("0") %>">
</strong></font></p>
<p align="left"><strong><font size="2" face="Arial, Helvetica, sans-serif">
<input name="pCalculate" type="button" id="pCalculate" value="Calculate" onClick="CalculateValues()">
<input name="pReset" type="button" id="pReset" value="Reset" onClick="Reset()">
</font></strong></p>
</div>
</form></td>



Mo
 
Oh yes, I changed that too after your first remark. The function name is also changed.

function CalculateValues()
{
var CurrTotal=document.getElementById('txtTotal').value * 1;
var Discount = 1-((document.getElementById('txtDiscount').value * 1)/100);
var ExtraCharges = parseInt(document.getElementById('txtExtraCharge').value * 1);
var DiscountAmt = (CurrTotal * Discount);
var NewTotal=(CurrTotal - DiscountAmt) + ExtraCharges;
document.getElementById('txtTotal').value = NewTotal;
return (true);
}

Mo
 

'txtExtraCharge' != 'txtExtraCharges'

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top