I have a grid question that contains check boxes and I want to put a custom label next to each check box.
Next, create a list for each row (or column) containing the labels that should be shown to respondents. For the grid shown above you will want 5 lists, one for each row. The lists are shown below.
Explanation of code
- Line 2 contains a jQuery anonymous function that should only be executed once all of the content on the page has been loaded and rendered on the screen and the document is ready for further interaction.
- Lines 3 through 9 creates an array of the labels, pulling directly from the pre-defined lists using SSI Script.
- Lines 10 through 15 are for loops that will iterate through the array created in lines 3 through 9. The first loop will cycle through the lists, the second loop through items in a list.
- Line 12 creates a selector that jQuery can use to find the cell label for the current loop iteration. If the grid was column oriented instead of grid oriented then the line would become
var selector = '.grid_r' + j + '.grid_c' + i + ' grid_cell_text';
- Line 13 relabels the cell so it contains the correct label from the correct list.
- Line 16 closes the anonymous function.
Please note that this script will only work if this is the only grid question on the page and that it is using the default grid question options.