-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.

1 Answer 1

-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
    });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.