Highlighted

Help asked with form script

Community Beginner ,
Nov 11, 2020

Copy link to clipboard

Copied

Hi,

A year ago I received help from someone on this forum and the form works well.  Now I needed to do some adjustments to the source file (Indesign) and I made a new pdf with text field properties. I checked with the old pdf and put in the same properties into the new pdf. But the calculation is not happening. 

 

What needs to happen is this: it's a form with yes (ja) or no (nee) answers. The 'ja' answers need to be counted and need to be displayed in the last line were it says: 'Totaal'. I copied the code from the old pdf into the new one and changed the text field id numbers. However the count is not happening. What is going wrong? I uploaded the file so you can take a look.

Many thanks in advance!

TOPICS
PDF forms

Views

55

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Help asked with form script

Community Beginner ,
Nov 11, 2020

Copy link to clipboard

Copied

Hi,

A year ago I received help from someone on this forum and the form works well.  Now I needed to do some adjustments to the source file (Indesign) and I made a new pdf with text field properties. I checked with the old pdf and put in the same properties into the new pdf. But the calculation is not happening. 

 

What needs to happen is this: it's a form with yes (ja) or no (nee) answers. The 'ja' answers need to be counted and need to be displayed in the last line were it says: 'Totaal'. I copied the code from the old pdf into the new one and changed the text field id numbers. However the count is not happening. What is going wrong? I uploaded the file so you can take a look.

Many thanks in advance!

TOPICS
PDF forms

Views

56

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 11, 2020 0
Adobe Community Professional ,
Nov 11, 2020

Copy link to clipboard

Copied

Change the field name in the script.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 11, 2020 0
Community Beginner ,
Nov 12, 2020

Copy link to clipboard

Copied

Hi Bernd,

Thanks for your repy. I saw that i uploaded a file with the old field id names, is that what you mean? I changed the script to the current id names, but still the form doesn't work.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

-

 

 

 

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0
Adobe Community Professional ,
Nov 12, 2020

Copy link to clipboard

Copied

Check the Javascript console (ctrl-j) for errors.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0
Adobe Community Professional ,
Nov 12, 2020

Copy link to clipboard

Copied

Replace:

// Initialize counter variable
var sum = 0;
// Loop through the fields
for (var i = 1; i <= 38; i += 1) {
// Add one if Tekstveld is set to ja
if (getField("Tekstveld " + i).valueAsString.toLowerCase()=="ja") {sum += 1;}
}
// Set this field's value to the sum
event.value = sum;

 

 

By:

// Initialize counter variable
var sum = 0;
// Loop through the fields
for (var i = 39; i < 76; i += 1) {
// Add one if Tekstveld is set to ja
if (getField("Text Field " + i).valueAsString.toLowerCase()=="ja") {sum += 1;}
}
// Set this field's value to the sum
event.value = sum;

 

Beware of blank spaces in the field name

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0
Engaged ,
Nov 12, 2020

Copy link to clipboard

Copied

See if this works for you Website-effectiviteitstest-10-11-2020 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 1
Community Beginner ,
Nov 12, 2020

Copy link to clipboard

Copied

Ah, I see now what Bernd meant with the Text field name. Yes, this works. I switched Adobe versions and now I'm working with a Dutch version. Thank you!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 12, 2020 0