Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

filling a text field based upon the numeric value of another field

New Here ,
Aug 28, 2024 Aug 28, 2024

I need some very basic help on filling a text field based upon the numeric value of another field. The form I am developing is the Adobe Acrobat Pro version of an assistive technology assessment and planning instrument for students with severe developmental and physical disabilities. My team and I originally published it in hardcopy format in the 1980’s.  The form contains 56 rating items that yield numeric values 0 to 10. For each of those values there is a line of specific text that needs to be placed in a specific field on the Results and Implications pages of the pdf. Will someone please provide me with an example of how to accomplish this?

TOPICS
Create PDFs , How to , JavaScript , PDF , PDF forms
492
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2024 Aug 28, 2024

Let's say ratings field is named "Rating1" use this as custom calculation script of the field where you wish to show text:

var rating = Number(this.getField("Rating1").valueAsString);

if(rating === 1)
event.value = "Text for rate 1";
else if(rating === 2)
event.value = "Text for rate 2";
else if(rating === 3)
event.value = "Text for rate 3";
//continue for rest of the ratings

else
event.value = "";

This is some basic script to do it, since you have a lot of fields if they are named correctly you could use loop to go over all fields with only one script.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2024 Aug 28, 2024

Thank you for your response. This is going to give you a clue to how new I am to trying to build this form with Acrobat.  When I am in "Prepare a Form" can I enter this script into the "Custom calculation script:" box associated with "text field properties." for the text field?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2024 Aug 28, 2024

Yes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2024 Aug 28, 2024

Enter a custom calulation in the text field where you want to display the result:

if(this.getField("Name of Numberic Value Field").value==5)

{event.value="The result when the field equals 5"}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2024 Aug 28, 2024

Thank you for your response. Would I have to repeat this script/code 11 times for each text field? There are 11 possible specific strings of text for each field on the Results page. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2024 Aug 28, 2024

var fldValue=this.getField("Name of Numberic Value Field").value;

if(fldValue==0)

{event.value="The result when the field equals 0"}

else if(fldValue.value==1)

{event.value="The result when the field equals 1"}

else if

...continue until 10th instance.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2024 Aug 28, 2024
LATEST

Thank You! I'll let you know how it goes. Thank you!

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