Want Checkbox to Autofill Based On Information From Another Field

New Here ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

I'm creating an employee evaluation form using Acrobat Pro DC. I have dropdown boxes for the evaluators to assign a ranking of 1 - 5 for each of twenty-five predescribed statements (e.g., "Excerses good judgement") in five categories (e.g., "Leadership", "Job Knowledge"). At the end of each category there is a field showing the average ranking for the five statements in that category. At the end of the categories there is a field (TotalAvgs) that tallies the five averages. Based on that total I wish to autopopulate a checkbox (or other type of box) in front of the applicable performance rating:

* Does Not Meet Expectations (<15)

* Meets the City's High Expectations (15-19.9)

* Exceeds Expectations (20-22.9)

* Far Exceeds Expectations (23-25)

 

I have written a few logic statements in Excel but don't yet understand how JavaScript works. Can anyone give me some pointers?

 

Not to be pesky but I forsee having two other questions, which I'll bring up after this one, related to Populating a header on all but the first page with the employee's name and How to have the document saved and emailed to the next approver of the evaluation after each signs (e.g. Supervisor, Department Head, HR, City Manager). 

 

Thank you for any help. 

TOPICS
Acrobat SDK and JavaScript, General troubleshooting, How to, PDF forms

Views

191

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
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Jul 15, 2020 Jul 15, 2020
PS. Are you sure the last check-box is not called "FarExceed"?

Likes

Translate

Translate
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

What's the name of the text field with the result, and what are the names of the check-box fields?

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Hello Most Valuable Participant try67,

Thank you for responding. The name of the text field with the result is TotalAvgs and the names of the four checkboxes are NotMeet, Meet, Exceed, FarExeed.

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
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Use this code as the custom validation or calculation script of the TotalAvgs field:

 

var v = event.value;
this.getField("NotMeet").checkThisBox(0, (v<15));
this.getField("Meet").checkThisBox(0, (v>=15 && v<20));
this.getField("Exceed").checkThisBox(0, (v>=20 && v<23));
this.getField("FarExeed").checkThisBox(0, (v>=23));

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
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

PS. Are you sure the last check-box is not called "FarExceed"?

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Mr. Try67, You totally called it! You created the script using my precise descriptions and then warned that it might be incorrect. It was. I corrected the spelling from FarExeed to FarExceed in the last checkbox and bingo! It works! Where can I send a Starbucks gift card?

 

Thank you so much!

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

No checkboxes are checked as a result of the value in TotalAvgs. I'm getting an error message in the console when changing any of the twenty-five dropdowns. 

 

ReferenceError: v is not defined

2:AcroForm:TotalAvgs:ValidateException in line 2 of function top_level, script 

AcroForm:TotalAvgs:Validate

 

 

 

 

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

The total for TotalAvgs is achieved by a calculation (sum of five Rank Avg). I applied your script as a Validation script. I've been trying to go through and verify that all texts in all fields are correct. Now, when I change any of the twenty-five dropdowns I get the following error message:

 

Exception in line 1 of function top_level, script AcroForm:TotalAvgs:Validate

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
community guidelines
Adobe Community Professional ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

That tells you there is an error on line 1.  Please post the validation code you are using.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
community guidelines
Most Valuable Participant ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

It's working fine for me... Did you change the code in any way?

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

I have gone back through multiple times to verify no typing errors.  I cut and pasted your script as a validation script to run along with the simple calculation that provides TotalAvgs its value. When I change any of the dropdowns I get the following error:

unnamed.png

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

I just recreated all the fields in a new document. I cut and paste the script and get the following error message whenever changing any of the dropdowns. Thank you for any help you can offer.

unnamed (1).png

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Is there a way to not have the NotMeet check-box checked when the form is cleared and TotalAvgs reads 0?

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
community guidelines
New Here ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

LATEST

Never mind. I learned a little something from try67 and added 0, (v>=1&&v<15)). Thanks Coach!

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
community guidelines