0 Replies Latest reply on Aug 31, 2009 1:57 PM by Delgadoworks

    Resolve Nodes - For Loop - Add.Instance - Sooo Close need help

    Delgadoworks

      I would like to write code that will loop through all of the instances in a dynamic table.    Once it finds the value 2,   I want it to return that value.  If 2 is not one of the options, I would like it to return zero.

       

       

      I sure hope there is someone out there that can help me. 

       

       

      Here are some examples of code,   I think I am very close

       

       

       

      ----- form1.Page1.Table8.Row1.Cell1::calculate: - (JavaScript, client) -----------------------------

      //This code totals all of the values in my index field

       

       

      var oFields = xfa.resolveNodes("form1.Page1.Table7.#subformSet[0].detail[*].index1");

      var nNodesLength = oFields.length;

      var nSum = 0;

       

      for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {

      nSum += oFields.item(nNodeCount).rawValue;

      }

      $.rawValue = nSum;

       

       

       

      ----- form1.Page1.Table8.Row1.Cell2::calculate: - (FormCalc, client) -------------------------------

       

      // this code will only return the a zero or a two from the first row of the table

       

      xfa.resolveNodes("form1.Page1.Table7.#subformSet[0].detail[*].index1")

       

      foreach Item in (form1.Page1.Table7.#subformSet[0].detail.index1) do

          if (form1.Page1.Table7.#subformSet[0].detail.index1.rawValue == 2)

          then $.rawValue = 2

          else $.rawValue = 0

          endif

       

      endfor

       

       

      ----- form1.Page1.Table8.Row1.Cell3::calculate: - (JavaScript, client) -----------------------------

      // this code returns the the value in the last instance of index1;

       

       

      var oFields = xfa.resolveNodes("form1.Page1.Table7.#subformSet[0].detail[*].index1");

      var nNodesLength = oFields.length;

      var i = 0;

      for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {

      var i = oFields.item(nNodeCount).rawValue;

      }

      this.rawValue = i;