Millisecond Forums

Values of multiple sliders added up into textbox

https://forums.millisecond.com/Topic35149.aspx

By falkenstone - 1/25/2023

Hello, 

I would like to add up the input of three sliders and print it in a separate textbox. In the end, when participants responded to all three sliders, the value in the textbox must be 15 and must not exceed this value.

Thanks for any help!
By Dave - 1/25/2023

falkenstone - 1/25/2023
Hello, 

I would like to add up the input of three sliders and print it in a separate textbox. In the end, when participants responded to all three sliders, the value in the textbox must be 15 and must not exceed this value.

Thanks for any help!

<values>
/ slidersum = 0
/ errormsg = " "
</values>


<block example>
/ trials = [1=sliderpage]
</block>

<surveypage sliderpage>
/ ontrialend = [
    values.slidersum = slider.a.response + slider.b.response + slider.c.response;
]
/ caption = "bla bla bla"
/ subcaption = "<%values.errormsg%>"
/ questions = [1=a; 2=b; 3=c]
/ showpagenumbers = false
/ showquestionnumbers = false
/ branch = [
    if (values.slidersum != 15) {
        values.errormsg = "Responses must add up to 15. Your responses added up to <%values.slidersum%>. Please try again.";
        return surveypage.sliderpage;
    };
]
</surveypage>

<slider a>
/ range = (1,9)
/ labels = ("1", "5", "9")
</slider>

<slider b>
/ range = (1,9)
/ labels = ("1", "5", "9")
</slider>

<slider c>
/ range = (1,9)
/ labels = ("1", "5", "9")
</slider>


You could add a text box displaying values.slidersum on a separate page if you really want to, but I'm not quite seeing the point of that and hence didn't include it.