0 Replies Latest reply on Mar 11, 2013 7:34 AM by ghenry20

    Need Help With Array Total Calculation

    ghenry20

      Hello,

       

      Posted a code a few days ago about getting an array working with comboboxes.  Well, I have all that working now but the issue I am having now is that I need the values need to be totaled in a single text box depending if the field is selected using the combobox.  The following is my working code:

       

      (function () {

          var Invoice = {};

      Invoice["Work Hour_1"] = event.value = this.getField("WorkCostsClaimed1").value;

      Invoice["Work Hour_2"] = event.value = this.getField("WorkCostsClaimed2").value;

      Invoice["Work Hour_3"] = event.value = this.getField("WorkCostsClaimed3").value;

      var vala = this.getField("InvoiceType1").value;

      var valb = this.getField("InvoiceType2").value;

      var valc = this.getField("InvoiceType3").value;

          if (vala in Invoice)

              event.value = Invoice[vala];

          if (valb in Invoice)

              event.value = Invoice[valb];

          if (valc in Invoice)

              event.value = Invoice[valc];

        })();

       

      The SummaryWorkCost1 field is the field that I need the value totals to be combined in.  The code I am trying to insert, in order to calculate the total value, is this:

       

       

      var starter = this.getField("SummaryWorkCost1");
      starter.editable = true;

      var j=0;

      var valTotal = Invoice[vala,valb,valc];
      for(j=0; j<valTotal.length;j++){
      starter.insertItemAt(valTotal[j],j);
      }

       

      Not sure if this is the correct code to use and if it is where/how to insert it.  Just looking for a few tips and thanks in advance!