Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Home
- >
- Acrobat SDK
- >
- How to Generate Numerical Score Based on Text Valu...

How to Generate Numerical Score Based on Text Value

New Here
,

Jul 19, 2019

Copy link to clipboard

Copied

I am trying to write script to apply a generate score based on selected text values in a drop down list. So for a field named "Likelihood" the values would be as follows -- Low; Low to Moderate; Moderate; Moderate to High; High. I want to produce a score based on each rating --

Low=1

Low to Mod=2

Mod=3

Mod to High=4

High=5

I have been able to write the script for the inverse where a numerical selection produces the text rating. But I need the opposite of that.

var v = this.getField("Dropdown1").value;

if (v=="") event.value = "";

else {

v = Number(v);

if (v<2) event.value = "Low";

else if (v<3) event.value = "Low to Moderate";

else if (v<4) event.value = "Moderate";

else if (v<5) event.value = "Moderate to High";

else if (v<6) event.value = "High";

}

TOPICS

Acrobat SDK and JavaScript

Community Guidelines

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

How to Generate Numerical Score Based on Text Value

New Here
,

Jul 19, 2019

Copy link to clipboard

Copied

I am trying to write script to apply a generate score based on selected text values in a drop down list. So for a field named "Likelihood" the values would be as follows -- Low; Low to Moderate; Moderate; Moderate to High; High. I want to produce a score based on each rating --

Low=1

Low to Mod=2

Mod=3

Mod to High=4

High=5

I have been able to write the script for the inverse where a numerical selection produces the text rating. But I need the opposite of that.

var v = this.getField("Dropdown1").value;

if (v=="") event.value = "";

else {

v = Number(v);

if (v<2) event.value = "Low";

else if (v<3) event.value = "Low to Moderate";

else if (v<4) event.value = "Moderate";

else if (v<5) event.value = "Moderate to High";

else if (v<6) event.value = "High";

}

TOPICS

Acrobat SDK and JavaScript

Community Guidelines

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

josephk69933065

Jul 19, 2019
0
/t5/acrobat-sdk/how-to-generate-numerical-score-based-on-text-value/td-p/10589524
1
Reply
1

try67
LATEST

Most Valuable Participant
,

Jul 19, 2019

Copy link to clipboard

Copied

Drop this line:

v = Number(v);

And reverse the if-conditions:

if (v=="Low") event.value = "2";

else if (v=="Low to Moderate") event.value = "3";

etc.

Community Guidelines

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

Reply

Loading...

try67

Jul 19, 2019
0
/t5/acrobat-sdk/how-to-generate-numerical-score-based-on-text-value/m-p/10589525#M10762
Using the Community
Experience League
Terms of Use
Privacy Policy
Cookie preferences
AdChoices
Language:

- Deutsch
- English
- Español
- Français
- 日本語コミュニティ
- Português

Copyright © 2020 Adobe. All rights reserved.