3 Replies Latest reply on Jan 29, 2016 12:04 PM by lisap63304215

    how to use spawning with a combo box and an array



      I have a form that I need to spawn pages.  As it is now I have a document array and a combo box.  When a selection is made in the combo box, the StateAmt field is populated from the array.  This all works fine now, but I need to be able to make this coding work with spawned pages and need a little help.


      This is my document javascript:

      var gState = new Array  //Create a reference to a new array

      //load the array up with the amounts for each state






      ....and so on, I deleted most to make the script shorter here


      this is my custom keystroke script  for combo box 'gstate' (fyi,  i added the state initials in the combo box options tab)

      var stateamt = this.getField("G876.StateAmt")

      if (event.changeEx in gState)

          stateamt.value = gState[event.changeEx]


      this works great for one page but when I add another page (spawned template) nothing happens after making a selection in the combo box.  I'm sure I need to alter the script due to spawning changes the field names on each page, but I don't know how.  I tried renaming the combo to gState1 and using this script (which does not work)


      var fna = event.target.name.split(".");

      var fp = fna.length>1?fna[0]+"."+fna[1]+".":"";

      var stateamt = this.getField(fp + "G876_StateAmt").name    // (this is G876.StateAmt on the original form)

      var gst = this.getField(fp + "gState1").name     //(this is gState on the original form)


      if (event.changeEx in gst)

          stateamt.value = gst[event.changeEx]



      If anyone can help me with this, I would be so grateful.