Have an idea?

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

Using Javascript to compare grid row value to next pages grid columns total value

Not sure why this is giving me so much grief, but I cannot seem to make it work and cannot find an example of this online. Please help!

I have grid question with 5 rows and 1 column, in column format with a total box at the bottom. For an example, the first row of this question is Cost of Goods Sold.  On the follow up pages there is a 3 row 1 column grid, in which we ask them to break down the number they gave on the previous page for Cost of Goods Sold by three locations. I need to write a script that compares the first row of first question to the total row of this follow up question. I am using SSI 66_18, so cannot use getvalue. I think this should be simple, but I have spent an hour banging my head against a wall :( Thank you!
asked Aug 29, 2014 by anonymous
edited Aug 29, 2014 by Walter Williams

1 Answer

0 votes
I'm not a JavaScript wizard like some of the forum users but I think you can achieve your result more easily by using a constant sum type question.

Lets say you have Q1 setup as a grid question or a constant sum question or even 5 numeric questions banked on the one page. They will all do the job.

Setup Q2 as a constant sum question with one column and 3 rows.

Set the value at Q2 in your TOTAL box under settings as [%Q1_r1%] or [%Q1_1%]  or [%Q1%], (depending on if you are using a grid, constant sum or numeric question at Q1).

So the total value at Q2 will force the addition of the 3 items at Q2 to equal the  value of the 1st box from Q1.

I just tested it and works real nice.
answered Aug 30, 2014 by Paul Moon Platinum (66,185 points)
edited Aug 30, 2014 by Paul Moon
Hi Paul,

Brilliant resolution to my problem! Thank you, that is way easier than writing the JS verification. Thanks so much