G
Guest
Hello,
I'm trying to set up an ASP.NET 2.0 form where the user enters values in
WebControls.TextBoxes for amount owing, interest and late fees and a
JavaScript function totals the three values and sets the value of a label
(lblTotal) to the sum of the three textbox values. The form is in a content
place holder.
I've added the following block of code in my form load.
The idea is to pass the three parameters to the update function:
txtAmount.Attributes.Add("onchange",
"update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);");
txtInterest.Attributes.Add("onchange",
"update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);");
txtLateFees.Attributes.Add("onchange",
"update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);");
function update(amt, itr, ltf)
{
var total = 0.00;
if(amt)
total += parseFloat(amt) ;
if(itr)
total += parseFloat(itr) ;
if(ltf)
total += parseFloat(ltf);
document.getElementById('ctl00$ContentPlaceHolder1$lblTotal').value =
total.toFixed(2);
}
</script>
The code appears to be failing with "object required" at this point. When
I debug in VS 2005 I get an "object required" error at the following code
block. It doesn't appear to recognize txtAmount.ClientID as a valid pointer
to the control.
<td style="width: 2px">
<input
name="ctl00$ContentPlaceHolder1$txtAmount" type="text"
id="ctl00_ContentPlaceHolder1_txtAmount"
onchange="update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);"
style="height:14px;width:100px;" /></td>
I'm a bit of a Javascript newbie and would sincerely appreciate any help I
could get here.
Thanks in advance,
Andre Ranieri
I'm trying to set up an ASP.NET 2.0 form where the user enters values in
WebControls.TextBoxes for amount owing, interest and late fees and a
JavaScript function totals the three values and sets the value of a label
(lblTotal) to the sum of the three textbox values. The form is in a content
place holder.
I've added the following block of code in my form load.
The idea is to pass the three parameters to the update function:
txtAmount.Attributes.Add("onchange",
"update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);");
txtInterest.Attributes.Add("onchange",
"update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);");
txtLateFees.Attributes.Add("onchange",
"update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);");
function update(amt, itr, ltf)
{
var total = 0.00;
if(amt)
total += parseFloat(amt) ;
if(itr)
total += parseFloat(itr) ;
if(ltf)
total += parseFloat(ltf);
document.getElementById('ctl00$ContentPlaceHolder1$lblTotal').value =
total.toFixed(2);
}
</script>
The code appears to be failing with "object required" at this point. When
I debug in VS 2005 I get an "object required" error at the following code
block. It doesn't appear to recognize txtAmount.ClientID as a valid pointer
to the control.
<td style="width: 2px">
<input
name="ctl00$ContentPlaceHolder1$txtAmount" type="text"
id="ctl00_ContentPlaceHolder1_txtAmount"
onchange="update(document.getElementById('txtAmount.ClientID').value,
document.getElementById('txtLateFees.ClientID').value,
document.getElementById('txtInterest.ClientID').value);"
style="height:14px;width:100px;" /></td>
I'm a bit of a Javascript newbie and would sincerely appreciate any help I
could get here.
Thanks in advance,
Andre Ranieri