PDF-Forms is a service provided by PDFzone.com | http://www.pdfzone.com/ __________________________________________________________________
Ask Leonard, he has all the $$$$$. ; ) -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of david lindblad Sent: Thursday, April 29, 2004 11:59 AM To: [EMAIL PROTECTED] Subject: Re: [PDF-Forms] Calculation of fields - division PDF-Forms is a service provided by PDFzone.com | http://www.pdfzone.com/ __________________________________________________________________ And on that note, I just found out Max will be hosting a three day seminar in Toronto... anyone have $1,195.00 US they are willing to loan to a lowly designer? Dave On 29-Apr-04, at 2:37 PM, Justice Gradowitz wrote: > > PDF-Forms is a service provided by PDFzone.com | > http://www.pdfzone.com/ > __________________________________________________________________ > > Thank you Max, you are right as usual. Can you use a formula like > this also work?: > > var a = this.getField("a") > var b = this.getField("b") > If(a.value(or whatever the dependent field is) != 0) event.value = > a.value / b.value else event.value = "" > > I have learned more from this forum than any other resource to date. > Thanks again for your insight. > > Justice > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Max Wyss > Sent: Thursday, April 29, 2004 11:25 AM > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [PDF-Forms] Calculation of fields - division > > > PDF-Forms is a service provided by PDFzone.com | > http://www.pdfzone.com/ > __________________________________________________________________ > > The standard answer is that you have set the format of the result > field (or another field depending on that result field) to "Number" of > some kind, AND that you have a division by zero. > > A division by zero results to "infinity", and a division of zero by > zero results to "NaN", which is Not a Number, and that is indeed true, > "Not a Number" is really not a number, and can not be formatted as a > number. > > Now, any division by zero leads to "illegal" results, which means that > the result of the division and any further calculation based on that > result will be illegal and therefore plain wrong. > > So, what do you do against that? > > Simple, you "protect" the calculation from being executed until the > conditions for it are fulfilled, which means that you have to make > sure that the number you divide by is not zero (or not an empty field). > > Let's assume our calculation is "value of field a" divided by "value > of field b". > > In the result field, we would then have the following Calculation > script: > > var a = this.getField("a") ; > var b = this.getField("b") ; > > event.value = a.value / b.value ; > > This will lead to the problems, but if we do the calculation only when > b.value is not zero, we will be on the safe side: > > if (b.value * 1) == 0) { > event.value = a.value / b.value ; > } > > By multiplying b.value with 1, we make sure that we have a valid > number. > > Hope, this can help. > > > Max Wyss > PRODOK Engineering > Low Paper workflows, Smart documents, PDF forms > CH-8906 Bonstetten, Switzerland > > Fax: +41 1 700 20 37 > or +1 815 425 6566 > e-mail: mailto:[EMAIL PROTECTED] > http://www.prodok.com > > > > [ Building Bridges for Information ] > > > ______________________ > > > > Shameless Plug: > > My next conference appearances and workshops: > * Conference presentations at the 2004 Symposium of the BFMA, May 23 > to > 27 in Reno, Nevada (http://www.bfma.org) and pre-/post-conference > workshop, May 22/23 and 27, organized by essociates Group > (http://www.essociatesgroup.com/AdvancedAcrobatForms.htm) > * And, as always, available for on-site workshops/tutorials/consulting. > > > _________________________ > > > >> I have a few forms on which I need to do division, at several >> locations, but when I add the JavaScript for division for the >> appropriate field, I get an error message for every field before I >> reach the fields used in the calculation. The message is the >> following > >> "The value entered does not match the format of the field (Field >> Name)". >> >> I have tried the solution recommended in the Tue, 15 May 2001 >> discussion, Subject [PDF-Forms] Blank Forms?????? >> but the same scenario occurs. >> >> I have Acrobat 5.0 To change your subscription: http://www.pdfzone.com/discussions/lists-pdfforms.html To change your subscription: http://www.pdfzone.com/discussions/lists-pdfforms.html
