Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Stepping thru a list of variables

Avatar

Level 2

Hi,

How can one step thru a list of variables without a long list of "If" statements? Each var gets a string consisting of one or more paragraphs used to fill a text box. The var is selected from a hierarchical list box.

EXample:

if (selectedValue == 1) {var TTHCov = dialogObject.TTHCov1;

  } else if (selectedValue == 2) {var TTHCov = dialogObject.TTHCov2;

  } else if (selectedValue == 3) {var TTHCov = dialogObject.TTHCov3;

  } else if (selectedValue == 4) {var TTHCov = dialogObject.TTHCov4;

  } else if (selectedValue == 5) {var TTHCov = dialogObject.TTHCov5;

  } else if (selectedValue == 6) {var TTHCov = dialogObject.TTHCov6;

  } else if (selectedValue == 7) {var TTHCov = dialogObject.TTHCov7;

  } else if (selectedValue == 8) {var TTHCov = dialogObject.TTHCov8;

  } else if (selectedValue == 9) {var TTHCov = dialogObject.TTHCov9;

  } else if (selectedValue == 10) {var TTHCov = dialogObject.TTHCov10;

  } else if (selectedValue == 11) {var TTHCov = dialogObject.TTHCov11;

  } else if (selectedValue == 12) {var TTHCov = dialogObject.TTHCov12;

  } else if (selectedValue == 13) {var TTHCov = dialogObject.TTHCov13;

  } else if (selectedValue == 14) {var TTHCov = dialogObject.TTHCov14;

  } else if (selectedValue == 15) {var TTHCov = dialogObject.TTHCov15;

  } else if (selectedValue == 16) {var TTHCov = dialogObject.TTHCov16;

  } else if (selectedValue == 17) {var TTHCov = dialogObject.TTHCov17;

  } else if (selectedValue == 18) {var TTHCov = dialogObject.TTHCov18;

  } else if (selectedValue == 19) {var TTHCov = dialogObject.TTHCov19;

  } else if (selectedValue == 20) {var TTHCov = dialogObject.TTHCov20;

  } else if (selectedValue == 21) {var TTHCov = dialogObject.TTHCov21;

  } else if (selectedValue == 22) {var TTHCov = dialogObject.TTHCov22;

  } else if (selectedValue == 23) {var TTHCov = dialogObject.TTHCov23;

  } else if (selectedValue == 24) {var TTHCov = dialogObject.TTHCov24;

  } else if (selectedValue == 25) {var TTHCov = dialogObject.TTHCov25;

  } else if (selectedValue == 26) {var TTHCov = dialogObject.TTHCov26;

  } else if (selectedValue == 27) {var TTHCov = dialogObject.TTHCov27;

  } else if (selectedValue == 28) {var TTHCov = dialogObject.TTHCov28;

  } else if (selectedValue == 29) {var TTHCov = dialogObject.TTHCov29;

  } else if (selectedValue == 30) {var TTHCov = dialogObject.TTHCov30;

  } else if (selectedValue == 31) {var TTHCov = dialogObject.TTHCov31;

  } else if (selectedValue == 32) {var TTHCov = dialogObject.TTHCov32;

  } else if (selectedValue == 33) {var TTHCov = dialogObject.TTHCov33;

  } else if (selectedValue == 34) {var TTHCov = dialogObject.TTHCov34;

  } else if (selectedValue == 35) {var TTHCov = dialogObject.TTHCov35;

  } else if (selectedValue == 36) {var TTHCov = dialogObject.TTHCov36;

  } else if (selectedValue == 37) {var TTHCov = dialogObject.TTHCov37;

  } else if (selectedValue == 38) {var TTHCov = dialogObject.TTHCov38;

  } else if (selectedValue == 39) {var TTHCov = dialogObject.TTHCov39;

  } else if (selectedValue == 40) {var TTHCov = dialogObject.TTHCov40;

  }

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi there, your list values are stored in an Object type, right?

So, e.g. if you have your data list enumerated like this :

var TTH = {"TTHCov1" : "value1",

                   "TTHCov2": "value2",

                    ....}

Hope this help!

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi there, your list values are stored in an Object type, right?

So, e.g. if you have your data list enumerated like this :

var TTH = {"TTHCov1" : "value1",

                   "TTHCov2": "value2",

                    ....}

Hope this help!

Avatar

Level 2

HI Magus069,

That's exactly what I did and it works great!

Fred