Have an idea?

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

need java script for Value A must be greater than or equal to Value B

we are testing hi/low values for pricing where the user inputs "too expensive" and "bargain" prices for a product .  

the 'too expensive' value must be greater than or equal to the 'bargain' value.

can anyone give me the java script for that? appreciate the help!
asked Mar 24, 2017 by clare (190 points)

1 Answer

0 votes
If the questions are on the same page, you can use this custom JavaScript verification:

if (SSI_GetValue('TooExpensiveQ') < SSI_GetValue('BargainQ')) {
    strErrorMessage = 'Error message here.';
}


If the questions are on different pages, you should put the verification on the latter page and use Sawtooth Script instead of SSI_GetValue for the question that appears on the former page:

if ([% TooExpensiveQ%] < SSI_GetValue('BargainQ')) {
    strErrorMessage = 'Error message here.';
}


if (SSI_GetValue('TooExpensiveQ') < [% BargainQ %]) {
    strErrorMessage = 'Error message here.';
}


For all of the above codes, "TooExpensiveQ" and "BargainQ" should be replaced with the names of those two questions.
answered Mar 24, 2017 by Zachary Platinum Sawtooth Software, Inc. (89,650 points)
...