Have an idea?

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

Free Format Question - one input in answer field should be higher than the other one

How can I create a free format question where the input of the second numeric text field should be higher than the first one and also third one should be higher than the second one.

... a good deal? <INPUT TYPE="number" NAME="Q30GoodDeal" maxlength="3"></input> USD/GBP per month <br /><br />
... expensive, but still acceptable? <INPUT TYPE="number" NAME="Q30Expensive" MAXLENGTH="3"></input> USD/GBP per month <i>(This answer should be higher than your first answer!)</i><br /><br />
... too expensive, and hence not considered as an option at all? <INPUT TYPE="number" NAME="Q30TooExpensive" MAXLENGTH="3"></input> USD/GBP per month <i>(This answer should be higher than your second answer!)</i><br /><br />
asked Jun 9 by jrskp (180 points)
It looks like you may be conducting a van Westendorp exercise in your questionnaire.  Is this correct?

1 Answer

0 votes
Hi, good question! I would probably do some kind of Custom JavaScript Verification for my FreeFormat question. That way, when my respondents hit the next button, they see an error and can fix their inputs.

Hit the Advanced button on the FF question, and paste this into the Custom JavaScript Verification tab (be sure to change the first three lines of code so they reference the names of your three numeric variables):
var val1 = SSI_GetValue("[%QuestionName()%]_number1");
var val2 = SSI_GetValue("[%QuestionName()%]_number2");
var val3 = SSI_GetValue("[%QuestionName()%]_number3");

if (val1 > val2) {
    strErrorMessage = "the first input cannot be larger than the second input.";
if (val2 > val3) {
    strErrorMessage = "the second input cannot be larger than the third input.";
answered Jun 10 by BethanyFry Bronze Sawtooth Software, Inc. (700 points)
Thanks for your help! Which parts in the first row should I change?
The first 3 lines of code grab the values for the three numeric variables in your Free Format question. So, you will need to update those lines with the names of your variables. Like this:

var val1 = SSI_GetValue("[%QuestionName()%]_GoodDeal");
var val2 = SSI_GetValue("[%QuestionName()%]_Expensive");
var val3 = SSI_GetValue("[%QuestionName()%]_TooExpensive");