forgot the .values on the end of each var, that's why it was putting in [object], 
should work now.

-----Original Message-----
From: Turetsky, Seth 
Sent: Monday, September 30, 2002 11:19 AM
To: '[EMAIL PROTECTED]'
Subject: RE: Adding two fields and displaying in a third


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#.value);
        var num2=new Number(eval(window.document.ExpenseForm.CostOfMeals#Line#.value);
        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


______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.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