Have an idea?

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

constants sum check

I need a total between 5 to 99999, if the total less than 5 then an error shows
related to an answer for: Constant sum Total Error
asked Dec 10, 2020 by Ali Raza Bronze (930 points)

1 Answer

0 votes
Just checking in here.

I thought you didn't want a validation check on the total? Is that correct?

If you now do, probably best you go with the numeric column grid approach.

You can use this JavaScript to keep the range within 5-99999.
var Item1=SSI_GetValue("Q1_r1_c1");
var Item2=SSI_GetValue("Q1_r2_c1");
var Item3=SSI_GetValue("Q1_r3_c1");
var Item4=SSI_GetValue("Q1_r4_c1");
var Item5=SSI_GetValue("Q1_r5_c1");

if ((Item1 + Item2 + Item3 + Item4 + Item5)<5)
 {
  strErrorMessage="The TOTAL MINIMUM is 5.";
 }
else if ((Item1 + Item2 + Item3 + Item4 + Item5)>99999)
 {
  strErrorMessage="The TOTAL MAXIMUM is 99999.";
 }
else
 {
  strErrorMessage="";
 }

Change your 5 grid variables to your variable names. You may also want to change the error text  displayed. You can also change the allowable range by changing the values in the "if" and "else if" statement lines.

This won't be the most efficient JavaScript, but it will work. I leave the serious JavaScript programming to the wizards like Zachary.
answered Dec 10, 2020 by Paul Moon Platinum (98,670 points)
...