Have an idea?

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

Slider question

I'm using the slider obtained from this thread:

https://www.sawtoothsoftware.com/forum.php?cmd=show&thread=1608&posts=3

However, I want to set the slider from 0 to 100 (not -100 to 100 as it is already), plus I want to make sure that a value is actually chosen, so the respondent cannot simply click "next without actually choosing anything. For example, the slider could sit by default on "-1", the scale is from "0 to 100", so they would actually have to move the slider to "0" to choose "0". Is there a way to do this? Or could someone please point me in the right direction in the code to change the options? I really appreciate any help. We are using version 7.
asked May 9, 2012 by anonymous
edited May 9, 2012 by Walter Williams
The old forum is no longer available.  The relevant post is copied here:

For anyone interested, below is the code that finally worked to get the slider going. It is based on WebFX's slider (  http://webfx.eae.net/dhtml/slider/slider.html  ).

You can download all necessary JavaScript and CSS files here:  http://webfx.eae.net/download/slider102.zip

Free Format question:
<input name="VAR_NAME" id="VAR_NAME" type="hidden" onchange="s.setValue(parseInt(this.value ))">

<p><div class="slider" id="slider-1" tabIndex="1">
 <input class="slider-input" id="slider-input-1"/>
</di v>


<script type="text/javascript">

v ar s = new Slider(document.getElementById("slider-1 "), document.getElementById("slider-input-1& quot;));
var s2 = new Slider(document.getElementById("slider-2 "), document.getElementById("slider-input-2& quot;), "vertical");
s.onchange = function () {
    document.getElementById("VAR_NAME& quot;).value = s.getValue();
    document.getElementById(&qu ot;h-min").value = s.getMinimum();
    document.getElementById(& quot;h-max").value = s.getMaximum();
    s2.setValue(s.getValue()) ;
    s2.setMinimum(s.getMinimum());
    s2.s etMaximum(s.getMaximum());
};
s.setValu e(0);

window.onresize = function () {
    s.recalculate();
};

</scri pt>



Head Tag:
<script type="text/javascript" src="[%GraphicsPath()%]range.js"></script>
<script type="text/javascript" src="[%GraphicsPath()%]timer.js"></script>
<script type="text/javascript" src="[%GraphicsPath()%]slider.js"></script>
<link type="text/css" rel="StyleSheet" href="[%GraphicsPath()%]bluecurve.css" />


Notice that there are three places where you need to enter the variable name for your free format question in the code above.

1 Answer

0 votes
I can't check the code now, but you can use javascript verification to make sure your variable is not -1 to continue.

As for -100 100 range, can't you just change -100 to 0?
answered May 9, 2012 by Bahadir Ozkurt Gold (16,930 points)
Thanks! I'm not sure where in the code to change the -100 to 0.
...