Values of multiple sliders added up into textbox


Author
Message
falkenstone
falkenstone
New Member (49 reputation)New Member (49 reputation)New Member (49 reputation)New Member (49 reputation)New Member (49 reputation)New Member (49 reputation)New Member (49 reputation)New Member (49 reputation)New Member (49 reputation)
Group: Forum Members
Posts: 5, Visits: 45
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!
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
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.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search