[thelist] function calculate()
Seb Barre
sebastien at oven.com
Mon Oct 23 10:09:51 CDT 2000
At 10:44 AM 10/23/2000 -0400, you wrote:
>Instead of getting a grand total in the BdCostTotal form field, I get an
>appended answer. Let's say I put the value
>1 in BdCost Advertising field and 2 in the BdCost Labor field. Instead of
>getting 3, I get 12. I tried adding "eval"
>before each (document.Front...) and received a NaN response.
>
>function calculate()
>{
>document.FrontPage_Form2.BdCostTotal.value =
>((document.FrontPage_Form2.BdCostAdvertising.value) +
>(document.FrontPage_Form2.BdCostLabor.value) +
>(document.FrontPage_Form2.BdCostTravel.value) +
>(document.FrontPage_Form2.BdCostDisposal.value) +
>(document.FrontPage_Form2.BdCostWarehouse.value) +
>(document.FrontPage_Form2.BdCostFreight.value) +
>(document.FrontPage_Form2.BdCostRepackaging.value) +
>(document.FrontPage_Form2.BdCostPostage.value) +
>(document.FrontPage_Form2.BdCostPrintedMaterial.value) +
>(document.FrontPage_Form2.BdCostProduct.value) +
>(document.FrontPage_Form2.BdCostProfits.value) +
>(document.FrontPage_Form2.BdCostSales.value))
>}
>
>If I'm asking elementary questions and you know of a list that would
>better suit
>my level, please advise of such list.
It sounds to me like one or more elements in your field values aren't
numbers (Javascript doesn't treat a null string as a number from what I
recall). You might want to put a default value of "0" in all your fields
to make sure that any empty ones are treated as numbers during your
math. Or you can use a cheap hack like
(document.FrontPage_Form2.BdCostAdvertising.value+1-1) + [...] and so on
.. The +1-1 will force it to a number. It's a hack, I know, but it should
work, if you're looking for a quick fix.
The 0 value in your fields is probably a better idea though, unless you
want the fields to be empty from the start, for design reasons..
--- -- -
Seb Barre - sebastien at oven.com
OVEN Digital Toronto
Work: 416-595-9750 x 222
Mobile: 416-254-5078
http://www.oven.com/
More information about the thelist
mailing list