• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Generate Numerical Score Based on Text Value

New Here ,
Jul 19, 2019 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

Views

176

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
Community Expert ,
Jul 19, 2019 Jul 19, 2019

Copy link to clipboard

Copied

LATEST

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.

Votes

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