Copy link to clipboard
Copied
There is a data list of 20 columns in the form. Initially I was writing the following code in all 20 fields. This was working as planned.
var x = event.target.name;
var i = x.slice(4);
var CheckA = this.getField("CheckA"+i);
if(CheckA.isBoxChecked(0)){event.value=1;}
else{event.value=0;};
I created the following simple function in document-level JavaScript.
function CalA() {
var x = event.target.name;
var i = x.slice(4);
var CheckA = this.getField("CheckA"+i);
if(CheckA.isBoxChecked(0)){event.value=1;}
else{event.value=0;};
}
And I tried to change the following code into 20 fields.
CalA();
There was no problem in the first field I changed. However, when I change the second field, debugging will start and the following display will appear.
TypeError: CalA is not a function
1:AcroForm:CalA1:Calculate
TypeError: CalA is not a function
1:AcroForm:CalA2:Calculate
What is happening and how can I resolve it?
1 Correct answer
There must be an error in the code that is keeping it from being defined.
Are there any errors reported in the Console Window (Ctrl-J)
I don't see any problems with your code, it should be working. So is there anything else in the document level script?
Can you post the entire code you placed in the Document Script?
Copy link to clipboard
Copied
There must be an error in the code that is keeping it from being defined.
Are there any errors reported in the Console Window (Ctrl-J)
I don't see any problems with your code, it should be working. So is there anything else in the document level script?
Can you post the entire code you placed in the Document Script?
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thank you for your reply. Unfortunately your advice probably doesn't seem to apply to my case. Because I haven't use any other document level code. Other comments do not appear in the console.
Copy link to clipboard
Copied
I have solved this problem just now. Thank you. There was a hint in your comment.
I was writing the following code in other Fields.
var x = event.target.name;
var i = x.slice(4);
var CalA = this.getField("CalA"+i);
var CalB = this.getField("CalB"+(i-1));
event.value = CalA.value + CalB.value;
I tried changing the function name of the code (function) I asked. Then the problem did not occur.

