[thelist] function calculate()

Mona_Nisoff at bd.com Mona_Nisoff at bd.com
Mon Oct 23 10:56:27 CDT 2000


Thanks for your ideas.  I tried adding the value="0" to the input fields.
Viewing the
changes in IE5 displayed 12 zeros in the grand total field.  So it displayed all
the fields'
values in order, it didn't add them.  ie; placing a 5 in the first field
displayed 500000000000.

So I tried the .value+1-1 approach.  It worked better but if I place a 5 in one
field and a
4 in another field, the answer is 90 instead of 9.

Thanks,
Mona




Seb Barre <sebastien at oven.com> on 10/23/2000 11:06:41 AM

Please respond to thelist at lists.evolt.org

To:   thelist at lists.evolt.org
cc:    (bcc: Mona Nisoff/RTP/BDX)
Subject:  Re: [thelist] function calculate()



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/


---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !










More information about the thelist mailing list