Anyone know how to get values from a text box grid question? I have two rows of four text boxes each (which capture numeric values) and I would need values for the first two in the first row. Looked into documentation on this, but can’t quite make sense of the arrays described and how these would work for me.
Appreciate your help!
Mihaly
Best answer
Here’s the custom script I use when I need to total up the responses in a textbox grid question:
%%grid_qid = 45; // Question ID of the grid
%%grid_colid = 10088; // Column or Option ID for the column you’re interested in (still needed if grid only has one column)%%total = 0; // Initialize running total
%%grid = sgapiGetValue(%%grid_qid); // Get an array of the responses to the grid question
foreach (%%grid as %%rowid => %%rowarray) { // Loop through each row in the grid
%%total += %%grid{%%rowid}{%%grid_colid}; // Add the response to our running total
}
Adapting that, I think if you want to directly access the responses in Row1/Column1 and Row1/Column2, then you can try this (replace %%grid_qid, %%rowid1, %%colid1, %%colid2 with your actual question ID for the grid question, the question ID for the first row, and the option IDs for the first two columns):
%%grid = sgapiGetValue(%%grid_qid);
%%r1c1 = %%grid{%%rowid1}{%%colid1};
%%r1c2 = %%grid{%%rowid1}{%%colid2};
Hi Oanh,
There are several different ways to do this. You can review the SurveyGizmo documentation for details:
https://help.surveygizmo.com/help/how-to-find-ids
https://help.surveygizmo.com/help/how-to-find-element-ids-to-use-with-javascript
Good luck!