If I have 4 columns and the 1st column a person enters a value between 1-10, I want it so that if they enter 1-3 it appears in the 2nd column, 4-6 it appears in the 3rd column and 7-10 it appears in the 4th column. How do I do that?

New Here ,
Jan 07, 2019

Copy link to clipboard

Copied

example.jpg

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

OK, I've written for you a generic function that you could use for all the fields. You just need to specify the min and max values.

The function code (which should be placed as a doc-level script) is:

function showScore(min, max) {

    var rowNumber = event.target.replace(/\D/, "");

    var v = Number(this.getField(rowNumber+"A").valueAsString);

    event.value = (v>=min && v<=max) ? v : "";

}

You then call it from the custom calculation script of your fields like this:

showScore(1,3);

Or:

showScore(4,6);

etc.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

58

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

If I have 4 columns and the 1st column a person enters a value between 1-10, I want it so that if they enter 1-3 it appears in the 2nd column, 4-6 it appears in the 3rd column and 7-10 it appears in the 4th column. How do I do that?

New Here ,
Jan 07, 2019

Copy link to clipboard

Copied

example.jpg

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

OK, I've written for you a generic function that you could use for all the fields. You just need to specify the min and max values.

The function code (which should be placed as a doc-level script) is:

function showScore(min, max) {

    var rowNumber = event.target.replace(/\D/, "");

    var v = Number(this.getField(rowNumber+"A").valueAsString);

    event.value = (v>=min && v<=max) ? v : "";

}

You then call it from the custom calculation script of your fields like this:

showScore(1,3);

Or:

showScore(4,6);

etc.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

59

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
Jan 07, 2019 0
Most Valuable Participant ,
Jan 07, 2019

Copy link to clipboard

Copied

What are the names of the 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
Reply
Loading...
Jan 07, 2019 0
New Here ,
Jan 07, 2019

Copy link to clipboard

Copied

Enter 1-10 is 1A, 1-3 is 1B, 4-6 is 1C, 7-10 is 1D then row 2 it is 2A, 2B, 2C, 2D and so on.

So if someone enters a 8 in 1A it will appear in both 1A and 1D.

Thank you so much for your help!

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...
Jan 07, 2019 0
Most Valuable Participant ,
Jan 07, 2019

Copy link to clipboard

Copied

OK, I've written for you a generic function that you could use for all the fields. You just need to specify the min and max values.

The function code (which should be placed as a doc-level script) is:

function showScore(min, max) {

    var rowNumber = event.target.replace(/\D/, "");

    var v = Number(this.getField(rowNumber+"A").valueAsString);

    event.value = (v>=min && v<=max) ? v : "";

}

You then call it from the custom calculation script of your fields like this:

showScore(1,3);

Or:

showScore(4,6);

etc.

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...
Jan 07, 2019 0