-4

I need to have more destinationColumn to fit in current development environment. For following example, it shows destinationColumn: 3, 4 and 5.

var columnSummary=  [

        {
            ranges: [[16, 19]],
            destinationRow: 20,
            destinationColumn: 3,
            type: 'sum',
            forceNumeric: true
        },
        {
            ranges: [[16, 19]],
            destinationRow: 20,
            destinationColumn: 4,
            type: 'sum',
            forceNumeric: true
        },
        {
            ranges: [[16, 19]],
            destinationRow: 20,
            destinationColumn: 5,
            type: 'sum',
            forceNumeric: true
        }
    ];

How to make program to generate mentioned array? Any help would be appreciated.

TwCloud
  • 1
  • 1

1 Answers1

-1

Based on How to create json by javascript for loop?

donohoe's code

<script>
//  var status  = document.getElementsByID("uniqueID"); // this works too
var status  = document.getElementsByName("status")[0];
var jsonArr = [];

for (var i = 0; i < status.options.length; i++) {
    jsonArr.push({
        id: status.options[i].text,
        optionValue: status.options[i].value
    });
}
</script>

I figured out the method to solve my own question, as follows:

var columnSummary = [];
for (var i = 3; i <= 12; i++) {
    columnSummary.push({
        ranges: [[16, 19]],
        destinationRow: 20,
        destinationColumn: i,
        type: 'sum',
        forceNumeric: true
    });
}
Community
  • 1
  • 1
TwCloud
  • 1
  • 1