thane,
it's trying to concatenate them instead of adding, try something like this(forcing the 
values into numbers then adding them):

<input type="Text" name="CostOfMeals#Line#" value="0" validate="float" 
required="Yes" size="5" maxlength="5" 
onchange= "
        var num1=new Number(eval(window.document.ExpenseForm.Mileage#Line#));
        var num2=new Number(eval(window.document.ExpenseForm.CostOfMeals#Line#));
        window.document.ExpenseForm.TotalAmount#Line#.value = num1 + num2;
        ">
hth
-seth

-----Original Message-----
From: Thane Sherrington [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 30, 2002 11:04 AM
To: CF-Talk
Subject: Adding two fields and displaying in a third


I'm writing a form that allows a person to fill in the mileage and meal 
expense, and then displays the total in a third field.  I'm using this in 
the meals expense field:

<input type="Text" name="CostOfMeals#Line#" value="0" validate="float" 
required="Yes" size="5" maxlength="5" 
onchange="window.document.ExpenseForm.TotalAmount#Line#.value=eval(window.document.ExpenseForm.Mileage#Line#)+eval(window.document.ExpenseForm.CostOfMeals#Line#);">

But the third field evaluates to [object][object].  How do I get this to 
add up?

T


______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to