These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

number to text logic error in PDF form

chardmont007
Registered: Mar 16 2011
Posts: 8
Answered

Hi guys
 
I'am newbie here.
I need some help, I got script here for NumberToWords, there's no error from the script, but has logic error,
here my simple explanation,
 
I have 10 field addition script, and the total amount I use as subject to NumberToWords, the logic error are delayed reaction of conversion, if I enter any figure in anyone in the field the NumberToWords field is late reaction, the previous total amount only read and convert to words.
 
ex.
100
250
150
Total 500
  
amount in words: Three Hundred Qatari Riyals Only
  
anyone can help me.
 
Thank in advance.

Richard M.

My Product Information:
Acrobat Pro Extended 9.4.2, Macintosh
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Most likely the field calculation order is incorrect. Go into Forms mode (Forms > Add or Edit Fields) and select "Forms > Edit Fields > Set Field Calculation Order", and set it to what makes sense for your form.
chardmont007
Registered: Mar 16 2011
Posts: 8
Thanks for the quick respond.

I'ld try this & set the field accordingly, but same effect, still delayed,hope anyone can help me,


Many thanks in advance


Richard M.

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
In what field and in what event (e.g., the Calculate event of the Total field) does the code get triggered?
chardmont007
Registered: Mar 16 2011
Posts: 8
here is the script in total amount field,

var a = this.getField("TOTALRow1"); // My 1st field
var b = this.getField("TOTALRow2"); // My 2nd field
var c = this.getField("TOTALRow3"); // My 3rd field
var d = this.getField("TOTALRow4"); // My 4th field
var e = this.getField("TOTALRow5"); // My 5th field
var f = this.getField("TOTALRow6"); // My 6th field
var g = this.getField("TOTALRow7"); // My 7th field
var h = this.getField("TOTALRow8"); // My 8th field
var i = this.getField("TOTALRow9"); // My 9th field
var j = this.getField("TOTALRow10"); // My 10th field
// using the Additional unity identity
event.value = (1 * a.value) +((1 * b.value) +(1 * c.value) +(1 * d.value) +(1 * e.value)
+(1 * f.value) +(1 * g.value) +(1 * h.value) +(1 * i.value) +(1 * j.value));
if (event.value==0) event.value="";


Richard M.

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
What about the code that generates the words, where and when is it triggered?
chardmont007
Registered: Mar 16 2011
Posts: 8
here's the triggered.

var f = this.getField("TOTAL AMOUNT");
event.value = ConvertToWords(f.value);

Richard M.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Make sure that the field that shows the number in words is calculated AFTER the total amount in numbers.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

chardmont007
Registered: Mar 16 2011
Posts: 8
thanks try67.

the number in words is calculating automatic, the only thing is, there is logic error, I cant really figure out what i missed.

I just new in scripting.

hope someone can help me in this matter.


Richard M.

chardmont007
Registered: Mar 16 2011
Posts: 8
anyone can help me in this logic error.


here's the attached file.
http://www.2shared.com/document/xbC2yD7v/sample_form.php

Thanks in advance.....

Richard M.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
(chardmont007 sent me the file by email)

Like I expected, the field calculation order is wrong.
Here's how to fix it:
- Go to Forms - Edit form in Acrobat
- Go (again) to Forms - Edit Fields - Set Field Calculation Order
- Move the field called "amount in words" below "TOTAL AMOUNT".
- Click OK.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

chardmont007
Registered: Mar 16 2011
Posts: 8
thanks try67.

what I'am setting is in the tab order only... now i saw the calculation order..


2 Thumbs up....


thanks.

Richard M.