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

Sum up values

New Here ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

Hi, how can I sum up the following values?

[A-H]&[J-U]&[W-Z]

[a-z]

[I,II, III, IV, V, VI, VII]

if (event.value=="A") { event.target.textColor = color.red;

        this.getField("Field1").textColor = color.red;

        this.getField("Field2").textColor = color.red;

        this.getField("Field3").textColor = color.red; }

else if (event.value=="B") { event.target.textColor = color.red;

        this.getField("Field1").textColor = color.red;

        this.getField("Field2").textColor = color.red;

        this.getField("Field3").textColor = color.red; }

else if (event.value=="C") { event.target.textColor = color.red;

        this.getField("Field1").textColor = color.red;

        this.getField("Field2").textColor = color.red;

        this.getField("Field3").textColor = color.red; }

else if (event.value=="D") { event.target.textColor = color.red;

        this.getField("Field1").textColor = color.red;

        this.getField("Field2").textColor = color.red;

        this.getField("Field3").textColor = color.red; }

else if (event.value=="a") { event.target.textColor = color.red;

        this.getField("Field1").textColor = color.red;

        this.getField("Field2").textColor = color.red;

        this.getField("Field3").textColor = color.red; }

else if (event.value=="b") { event.target.textColor = color.red;

        this.getField("Field1").textColor = color.red;

        this.getField("Field2").textColor = color.red;

        this.getField("Field3").textColor = color.red; }

else if (event.value=="c") { event.target.textColor = color.red;

        this.getField("Field1").textColor = color.red;

        this.getField("Field2").textColor = color.red;

        this.getField("Field3").textColor = color.red; }

else if (event.value>=0) { event.target.textColor = color.black;

          this.getField("Field1").textColor = color.black; 

        this.getField("Field2").textColor = color.black;

        this.getField("Field3").textColor = color.black; }

else if (event.value=="I") { event.target.textColor = color.green;

    this.getField("Field1").textColor = color.green;

    this.getField("Field2").textColor = color.green;

    this.getField("Field3").textColor = color.green; }

else if (event.value=="II") { event.target.textColor = color.green;

    this.getField("Field1").textColor = color.green;

    this.getField("Field2").textColor = color.green;

    this.getField("Field3").textColor = color.green; }

else if (event.value=="III") { event.target.textColor = color.green;

    this.getField("Field1").textColor = color.green;

    this.getField("Field2").textColor = color.green;

    this.getField("Field3").textColor = color.green; }

else if (event.value=="IV") { event.target.textColor = color.green;

    this.getField("Field1").textColor = color.green;

    this.getField("Field2").textColor = color.green;

    this.getField("Field3").textColor = color.green; }

else if (event.value=="V") { event.target.textColor = color.green;

    this.getField("Field1").textColor = color.green;

    this.getField("Field2").textColor = color.green;

    this.getField("Field3").textColor = color.green; }

else event.target.textColor = color.blue;

as well I would like to sum up the "get.Field" method. I tried this:

this.getField(["Field1","Field2","Field2"]).textColor = color.red;

but it didn't work

can you please help me?

TOPICS
Acrobat SDK and JavaScript

Views

875

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

Community Expert , Aug 06, 2019 Aug 06, 2019

OK, then I would do it like this:

var newTextColor = color.black;

var romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII"];

if (romanNumerals.indexOf(event.value)!=-1) {

    newTextColor = color.green;

} else if (/^\d+$/.test(event.value)) {

    newTextColor = color.blue;

} else if (/^[a-z]+$/i.test(event.value)) {

    newTextColor = color.red;

}

var fields = ["Field1", "Field2", "Field3"];

for (var i in fields) this.getField(fields).textColor = newTextColor;

Votes

Translate

Translate
Community Expert ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

Are these the only options?

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
New Here ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

what do you mean with the only options?

edit:

there's a table with 30 rows and 3 columns. actually there are more options. field 1-3 only represents one row in this table

the color of one row should depend on the value that ist entered in the target field

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
Community Expert ,
Aug 05, 2019 Aug 05, 2019

Copy link to clipboard

Copied

I mean if the only options are the lower and upper case letters and I-VI in Roman numerals.

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
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

the options are lower and upper case letters, roman numerals I-VII and numbers

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
Community Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

OK, then I would do it like this:

var newTextColor = color.black;

var romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII"];

if (romanNumerals.indexOf(event.value)!=-1) {

    newTextColor = color.green;

} else if (/^\d+$/.test(event.value)) {

    newTextColor = color.blue;

} else if (/^[a-z]+$/i.test(event.value)) {

    newTextColor = color.red;

}

var fields = ["Field1", "Field2", "Field3"];

for (var i in fields) this.getField(fields).textColor = newTextColor;

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
Community Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

trompete111  schrieb

what do you mean with the only options?

edit:

there's a table with 30 rows and 3 columns. actually there are more options. field 1-3 only represents one row in this table

the color of one row should depend on the value that ist entered in the target field

What are the field names in the other rows?

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
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

well I think I'll just number them eg Field11, Field 12, Field 13, Field 21, Field22, Field23,.. are there any other options?

thank you try67​ this is exactly what I was searching for. but i don't really understand wherefore you define

  1. var newTextColor = color.black; 

is this because of the presetting of the color? so that every field with the preset textcolor black is affected on the entered value or is it just random?

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
Community Expert ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

LATEST

That's in case the value doesn't match any of the conditions.

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