Javascript for auto populating a text field based on the value from another field.

New Here ,
Jul 19, 2018

Copy link to clipboard

Copied

I have a form set up for users to score individuals in 8 categories. At the bottom of the form, I have created a field that adds up all of the previous scores that I'll refer to as TOTAL SCORE. I now want to create a text field that will automatically display certain text (5 possible values) when the value of TOTAL SCORE falls within a certain range.

For example,

If the TOTAL SCORE field is > 16, I want the text box field to automatically populate to say "UNACCEPTABLE".

If the TOTAL SCORE field is between 16-23, I want the text box field to automatically populate to say "NEEDS IMPROVEMENT".

If the TOTAL SCORE field is between 24-31, I want the text box field to automatically populate to say "MEETS REQUIREMENTS".

If the TOTAL SCORE field is between 32-39, I want the text box field to automatically populate to say "EXCEEDS REQUIREMENTS".

If the TOTAL SCORE field is equal to 40, I want the text box field to automatically populate to say "OUTSTANDING".

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Assuming so, you can use this code as the custom calculation script of the field where you want to display the result:

var totalScore = Number(this.getField("TOTAL SCORE").valueAsString);

if (totalScore<16) event.value = "UNACCEPTABLE";

else if (totalScore>=16 && totalScore<=23) event.value = "NEEDS IMPROVEMENT";

else if (totalScore>=24 && totalScore<=31) event.value = "MEETS REQUIREMENTS";

else if (totalScore>=32 && totalScore<=39) event.value = "EXCEEDS REQUIREMENTS";

else if (totalScore==40) event.value = "OUTSTANDING";

TOPICS
Acrobat SDK and JavaScript, Windows

Views

235

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

Javascript for auto populating a text field based on the value from another field.

New Here ,
Jul 19, 2018

Copy link to clipboard

Copied

I have a form set up for users to score individuals in 8 categories. At the bottom of the form, I have created a field that adds up all of the previous scores that I'll refer to as TOTAL SCORE. I now want to create a text field that will automatically display certain text (5 possible values) when the value of TOTAL SCORE falls within a certain range.

For example,

If the TOTAL SCORE field is > 16, I want the text box field to automatically populate to say "UNACCEPTABLE".

If the TOTAL SCORE field is between 16-23, I want the text box field to automatically populate to say "NEEDS IMPROVEMENT".

If the TOTAL SCORE field is between 24-31, I want the text box field to automatically populate to say "MEETS REQUIREMENTS".

If the TOTAL SCORE field is between 32-39, I want the text box field to automatically populate to say "EXCEEDS REQUIREMENTS".

If the TOTAL SCORE field is equal to 40, I want the text box field to automatically populate to say "OUTSTANDING".

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Assuming so, you can use this code as the custom calculation script of the field where you want to display the result:

var totalScore = Number(this.getField("TOTAL SCORE").valueAsString);

if (totalScore<16) event.value = "UNACCEPTABLE";

else if (totalScore>=16 && totalScore<=23) event.value = "NEEDS IMPROVEMENT";

else if (totalScore>=24 && totalScore<=31) event.value = "MEETS REQUIREMENTS";

else if (totalScore>=32 && totalScore<=39) event.value = "EXCEEDS REQUIREMENTS";

else if (totalScore==40) event.value = "OUTSTANDING";

TOPICS
Acrobat SDK and JavaScript, Windows

Views

236

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
Jul 19, 2018 0
Most Valuable Participant ,
Jul 19, 2018

Copy link to clipboard

Copied

In the first line, do you mean if TOTAL SCORE is < 16 ?

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...
Jul 19, 2018 0
Most Valuable Participant ,
Jul 19, 2018

Copy link to clipboard

Copied

Assuming so, you can use this code as the custom calculation script of the field where you want to display the result:

var totalScore = Number(this.getField("TOTAL SCORE").valueAsString);

if (totalScore<16) event.value = "UNACCEPTABLE";

else if (totalScore>=16 && totalScore<=23) event.value = "NEEDS IMPROVEMENT";

else if (totalScore>=24 && totalScore<=31) event.value = "MEETS REQUIREMENTS";

else if (totalScore>=32 && totalScore<=39) event.value = "EXCEEDS REQUIREMENTS";

else if (totalScore==40) event.value = "OUTSTANDING";

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...
Jul 19, 2018 1
New Here ,
Jul 19, 2018

Copy link to clipboard

Copied

Awesome! Thank you, it's working great!

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...
Jul 19, 2018 0