Skip to main content
Participant
July 11, 2022
Answered

Need a form field (lines verified) to return a value.

  • July 11, 2022
  • 3 replies
  • 670 views

I need a field (lines verified), to show if there is data in a group of other fields. i.e 5 fields, only three have data. I need the lines verified field to show 3.

Hope I explained somewhat

Yes, I am new to scripting

TIA

This topic has been closed for replies.
Correct answer try67

You can use this code as the custom calculation script of the "lines verified" field to do it (just adjust the field names in the first line):

 

var fields = ["Text1", "Text2", "Text3"];
var totalFilled = 0;
for (var i in fields) {
	if (this.getField(fields[i]).valueAsString!="") totalFilled++;
}
event.value = totalFilled;

3 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 12, 2022

You can use this code as the custom calculation script of the "lines verified" field to do it (just adjust the field names in the first line):

 

var fields = ["Text1", "Text2", "Text3"];
var totalFilled = 0;
for (var i in fields) {
	if (this.getField(fields[i]).valueAsString!="") totalFilled++;
}
event.value = totalFilled;
Participant
July 14, 2022

Hi ,

Thanks for the sript.

I really need to learn this.

Thanks again I appreciate this.

ls_rbls
Community Expert
Community Expert
July 12, 2022

You need to be specific about what exactly do you mean by verified.

 

Are you trying to perform anarithmetic calculation that shows the total in another field ? (for example)

 

If yes, you can use the built-in calculating features or employ a JavaScript script.

 

Otherwise, please describe in more detail what type of values are contained in those text fields (i.e. names, numbers, fractions, decimals)

Participant
July 12, 2022

Hello and thanks.

This document is like an invoice; a list of 10 items each with a field for quantities. On the invoice there is a field that needs to verify if there is a quntity in any or all of the quantity fields, not a sum only if there is an entry.

Amal.
Legend
July 11, 2022

Hi Alan

 

Hope you are doing well and thanks for reaching out.

 

The workflow you are trying to achieve is possible using JavaScript. For more information please check the help pages listed below:

https://acrobatusers.com/tutorials/javascript_console/

https://helpx.adobe.com/acrobat/using/applying-actions-scripts-pdfs.html

 

Hope it will help

 

Regards

Amal