Populate text field if a number falls within a specific range

New Here ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

Hello! I'm hoping someone here can help me with this. I'm working on a form in Adobe Acrobat XI. The form is basically a survey that uses radio buttons. Each choice has an associated numerical value, and these values must be totaled to give the user a score. I've figured out how to get a total score based on the values of the radio buttons selected, and am using a calculation in a hidden field to do that. Now I'd like to use text fields to display the score next to the appropriate range, but I don't know how to do so. There are four ranges, and I'd like for it only to display next to the appropriate one. How would I do that, assuming the name of the hidden field is "Total"? So in the picture below, if the user had a score of 30, it would show up in a text field to the left of the "26-38" range, but not in the other three boxes.

Screenshot 2017-08-14 17.01.04.png

TOPICS
PDF forms

Views

569

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

Adobe Community Professional , Aug 14, 2017 Aug 14, 2017

No, that's fine. Leave it as is.

As the custom calculation script of "16-24", for example, use this script:

var total = Number(this.getField("Total").value);

if (total>=16 && total<=24) event.value = total;

else event.value = "";

You can use the same code for the other fields, just adjust the values in the second line.

Likes

Translate

Translate
Adobe Community Professional ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

Are you using a custom calculation script for the Total field, or one of the other options?

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 ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

Right now I'm using the "Value is the Sum" option, but am open to changing that.

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 ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

No, that's fine. Leave it as is.

As the custom calculation script of "16-24", for example, use this script:

var total = Number(this.getField("Total").value);

if (total>=16 && total<=24) event.value = total;

else event.value = "";

You can use the same code for the other fields, just adjust the values in the second line.

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 ,
Aug 14, 2017 Aug 14, 2017

Copy link to clipboard

Copied

That works perfectly! 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
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

LATEST

hi I have a similar problem. If I want to set it up as 20 + or - a certain range is there an elegant way to write the if statement?

var total = Number(this.getField("Total").value);

var range = Number(this.getField("Range").value);

if (total>=20 + range && total<=20 + range) event.value = total;

 

something like this?

 

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