Have an idea?

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

Bringing forward Multiple answers into Grid type question

Here's my scenario.

I have a list at S5, there are 12 items in the list and the respondent needs to enter in how many they OWN of each of these items.  If they own at least 1 piece, they are then put into a Purchase List...(I'll call this NEW list Equipment)
                               TOTAL OWNED
1.Item 1                       # Owned
2.Item 2                      # Owned
3. Item 3                     # Owned
4. Item 4                     # Owned
5. Item 5                     # Owned
Etc... for the 12 items...

So, for reference,  I know how to do this list building skill, however here is my question... I need to BRING FORWARD each item  from this Newlist PLUS the # Owned into a new grid type question.  So the respondent would see for instance:

Item 1 - 5
Item 3 - 6
Item 5 - 2

THEN, in this same grid, they want the respondent to be able to enter in the Number they purchased within the past year... HOW do I get both the list name and the number purchased to pull forward, plus have a numeric response in a grid for them to answer how many pieces they purchased in the past year??? I'm struggling. Thank you for your help...
asked Jul 10 by anonymous

1 Answer

+1 vote
It is not possible to add text to a list item, but you can instead add the number of items owned to the grid question with a little JavaScript.  I put this code into my second grid's footer to achieve this effect:

<script>
$(document).ready(function(){
    var values = [% Begin Unverified Perl
        my @arr = ();
        for (my $i = 1; $i <= 12; $i++) {
            push @arr, GETVALUE('GridQ1_r' . $i . '_c1');
        }
        return '[' . join(',',@arr) . ']';
        End Unverified %];
    $('input[name=hid_row_list_[% QuestionName() %]]').val().split(',').forEach(function(row){
        var value = values[row - 1];
        var gridOptions = $('#[% QuestionName() %]_r' + row + '_row .grid_options');
        $(gridOptions).text($(gridOptions).text() + ' - ' + value);
    })
})
</script>


Be sure to replace "GridQ1" with the name of the first grid question.
answered Jul 10 by Zachary Platinum Sawtooth Software, Inc. (63,900 points)
...