Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Display the Row label

Hello,

I am using the below code

   
var rows = $('input[name="hid_row_list_[% QuestionName() %]"]').val().split(',');
rows.forEach(function(row){​​​​​​​


if ([%Q4%] == 1)
{​​​​​​​ 
    if (SSI_GetValue('[% QuestionName() %]_r' + row + '_c2') != SSI_GetValue('[% QuestionName() %]_r' + row + '_c3'))  {​​​​​​​
        strErrorMessage = "Error + rows";
    }​​​​​​​
}​​​​​​​
}​​​​​​​ );



and I would like to display the row label list member in my error message.    How would I do this?

Thank you
related to an answer for: Javascript verification
asked Jan 13 by Sandy

1 Answer

0 votes
Two main options come to mind.

For the Sawtooth Script option, I would add this near the beginning of your code, replacing "list1" with your row list:

var rowsList = [% ListLabelsArray(list1) %];


Then you can pull row labels from that array:

strErrorMessage = 'Error for row ' + rowsList[row - 1];


For the pure JavaScript option, you can update your error text like this:

strErrorMessage = 'Error for row ' + $('#[% QuestionName() %]_div .row_label_cell.grid_r' + row).text();
answered Jan 13 by Zachary Platinum Sawtooth Software, Inc. (161,250 points)
...