Have an idea?

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

Grid with checkbox and numeric fields and verification of answers

I need to build a grid (asked row-wise) that should ideally look like the following example:

Rows: How much did you spend for "..."

1st column: Checkbox "nothing"
2nd column: Numeric input (expenses per day)
3rd column: Numeric input (expenses for whole stay)
4th column (optional): Checkbox "No answer" - this could also be integrated into the numeric field as "N/A" value.

Only one of the 3 (or 4) columns can be answered per row.
Is this possible and does anyone have an idea how to solve it?
asked Dec 16, 2015 by guido (145 points)

1 Answer

0 votes
A grid can contain a mixture of various types of inputs such as radio buttons, check boxes, numeric inputs, etc.

Setup a one row grid with your 3 or 4 columns and label each column accordingly.

Make the grid direction equal to column.

Now click on the first column member in your list and click edit. A new window will appear which enables you to select the input type and apply the various settings.

Repeat this step for all columns.

Now you have the look of the grid.

To control the input, you will require JavaScript that needs to be inserted into the Advanced / Custom JavaScript Verification window.
answered Dec 17, 2015 by Paul Moon Platinum (61,560 points)
Thanks Paul!

I was so focused on the row-wise direction that I missed the column-wise setup with JavaScript verification... Works perfectly.
Hi Paul, I had a similar problem. Can you please help tell me what the JavaScript code would look like? I wrote up some scripts but it failed to run. Thanks!
Hi Maggie,

in my case (Grid named A14)  the code looks like this:

 var A14_2_NO=SSI_GetValue('A14_r1_c1'); // this is check box for "nothing"
 var A14_2_1=SSI_GetValue('A14_r1_c2');  // this is numeric input from 1 to 99999
 var A14_2_2=SSI_GetValue('A14_r1_c3');  // this is numeric input from 1 to 99999
 var A14_2_DK=SSI_GetValue('A14_r1_c4'); // this is check box for "dk"
 
  if(A14_2_1>0 && (A14_2_NO==1 || A14_2_DK==1 || A14_2_2>0))
{
    strErrorMessage = "Only one answer per row!";
}

 if(A14_2_2>0 && (A14_2_NO==1 || A14_2_DK==1 || A14_2_1>0))
{
    strErrorMessage = "Only one answer per row!";
}

 if(A14_2_NO==1 && (A14_2_1>0 || A14_2_DK==1 || A14_2_2>0))
{
    strErrorMessage = "Only one answer per row!";
}

 if(A14_2_DK==1 && (A14_2_1>0 || A14_2_NO==1 || A14_2_2>0))
{
    strErrorMessage = "Only one answer per row!";
}
 
 if(A14_2_NO==0 && A14_2_1==0 && A14_2_2==0 && A14_2_DK==0)
{
    strErrorMessage = "Only one answer per row!";
}

It may not be perfectly optimized, but it works.
Thanks for filling in the answer Guido. Appreciated.
thanks guido and Paul! this is very helpful.
...