Skip to main content
Known Participant
March 21, 2018
Question

Export value is not calculating

  • March 21, 2018
  • 1 reply
  • 853 views

Good morning!

I'm trying something new and looking for a little help : )

I assigned export values to some drop down selections in my form. The values are not calculating in the score field I set up. The score field has a custom script which uses a copy of the drop down fields arranged in an array.

This script works on other forms with number fields validated from 0-4.

What could be keeping the export values of the drop down selections from calculating? Could it be the way I'm naming the fields?

When I try to change the format of the drop down fields to Number, I get a message saying, "The format does not match one or more values specified in the dropdown list. To change the format for this dropdown, first change the dropdown list values in the Options panel to match this format," although, I have assigned each dropdown selection an export value ranging from 0 to 4.

Any suggestions?

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
March 21, 2018

What kind of calculation did you set up? How did you implement it? If you used a script, post the code.

ANP55Author
Known Participant
March 21, 2018

There are a few sets of questions with drop down selections at the end of each question. Another table is set up at the very end to display percentages for each set of questions.

In the table at the end, each array is hidden and each array leads to a visible score field.

This is what each score field does. I'm thinking it doesn't work because my new form has different names for the fields (which I did enter into the script) or I need to do something else with the dropdown aspect:

var fieldsObj = [["Field1","Score1"], ["Field2","Score2"]];

for (var i in fieldsObj) {

    calcAll(fieldsObj[0], fieldsObj[1]);

}

function calcAll(FieldArrName, FieldScoreName) {

    var f = this.getField(FieldArrName);

    var a = f.getArray();

    var isNotNull = false;

    var termSum = 0;

    var calcDen = 0;

    for (var j=0; j<a.length; j++) {

        if (a.value != a.defaultValue) {

         isNotNull = true;

          termSum += a.value;

          calcDen++;

        }

    }

     

    var s = this.getField(FieldScoreName);

    if (isNotNull){

        s.value = 2* termSum/(calcDen*8);

    }

    else {

        s.value = "";

    }

}

try67
Community Expert
Community Expert
March 21, 2018

Are there any error messages in the JS Console?