Have an idea?

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

Calculation based on slider on the same page

I use a semantic differential with a slider. Based on the value of the slider I want to do some calculations and display them in a numeric field directly on the same page. I've done this with javascript in free format questions before, but there is no slider available in free format.
There should be something like a javascript event when the slider is changed.
Any help is appreciated!
asked Aug 13, 2014 by anonymous

1 Answer

0 votes
 
Best answer
There is probably a way, but I'm having a hard time figuring out how to attach a listener to the semantic differential questions.

If you're using Free Format question with a jQuery UI slider (http://jqueryui.com/slider/#default) you should be able to grab the current value of the slider and use it in a calculation using the following :
$( "#sliderid" ).slider( "value" )


or if you want to bind a listener to the "slide" event you can add one using the following code:
$( ".selector" ).on( "slide", function( event, ui ) {} );

wherein you can reference ui.value for the current value of the slider. This would allow you to run the change as the respondent is sliding the bar.
answered Aug 13, 2014 by Kenneth Fairchild Bronze Sawtooth Software, Inc. (3,095 points)
Thank you very much for your answer. I went using the free format solution and it works fine!
Probably just as easy to do as free format, but if you edit the ssi_javascript file in the /graphics/system folder you can edit the SSI_SliderSetup function directly to add stuff to the change/slide events. Just need to be careful it doesn't get overwritten or carries on to other studies unintentionally. This is the only way I've found to get the tool tip positioning exactly as I want it without starting from scratch.
Thank you so much for your answer.
...