1

I have a form with the structure: Form1

  • parentSection1
    • childSection1
    • childSection2
    • childSection3... etc

I have made an array of all the childSection names (currentParent[]) and need to use it in a variable that accesses the nodes of each childSection.

var childNode = Form1.parentSection1.childSection1.nodes;  // this works if I reference it directly

what I need to work but can't get the syntax correct is:

var childNode = Form1.parentSection1.currentParent[i].nodes; // where i loops within a larger function

Any help would be much appreciated! Thanks!

Pointy
  • 405,095
  • 59
  • 585
  • 614
meee
  • 23
  • 4
  • You probably mean `var childNode = Form1.parentSection1[currentParent[i]].nodes;` – jabaa Jun 14 '23 at 02:07
  • What is the type for `parentSection`, and what loop are you using? if it's a `NodeList` - which is not a traditional array - you may want to revisit how you loop over it. https://developer.mozilla.org/en-US/docs/Web/API/NodeList – painotpi Jun 14 '23 at 02:10
  • ``var childNode = Form1.parentSection1[`currentParent${i}`].nodes;`` – Megrax Jun 14 '23 at 02:23

0 Answers0