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

Sum up values

New Here ,
Aug 05, 2019 Aug 05, 2019

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
1.1K
Translate
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;

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

Are these the only options?

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

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;

Translate
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

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?

Translate
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

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?

Translate
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
LATEST

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

Translate
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