JavaScript Range Slider
Open in new window

Survey.Survey.cssType = "bootstrap";
Survey.defaultBootstrapCss.navigationButton = "btn btn-green";

Survey.JsonObject.metaData.addProperty("checkbox", {name: "renderAs", default: "standard", choices: ["standard", "nouislider"]});

window.survey = new Survey.Model({ questions: [{
    type: "checkbox", renderAs: "nouislider", name: "range", title: "Please range"
}]});
survey.onComplete.add(function(result) {
	document.querySelector('#surveyResult').innerHTML = "result: " + JSON.stringify(result.data);
});


var widget = {
    name: "nouislider",
    htmlTemplate: "<div id='slider'></div>",
    isFit : function(question) { return question["renderAs"] === 'nouislider'; },
    afterRender: function(question, el) {

        var slider = el.querySelector("#slider");

        noUiSlider.create(slider, {
        	start: (question.value && question.value.length) ? question.value : [30, 70],
        	connect: true,
            pips: {
                mode: 'steps',
                stepped: true,
                density: 4
            },
        	range: {
        		'min': 0,
        		'max': 100
        	}
        });

        slider.noUiSlider.on('set', function(){
        	question.value = slider.noUiSlider.get();
        });     
    }
    
        ,
        willUnmount: function(question, el) {
            var slider = el.querySelector("#slider");
            slider.noUiSlider.destroy(); 
        } 
    
}
Survey.CustomWidgetCollection.Instance.addCustomWidget(widget);
survey.data = { range: ["20.00", "80.00"] };


$("#surveyElement").Survey({
    model: survey
});



<!DOCTYPE html>
<html>

<head>
    <title>Welcome to JQuery</title>
    <script src="https://unpkg.com/jquery"></script>
    
    <script src="https://surveyjs.azureedge.net/0.12.22/survey.jquery.js"></script>
    
    
    <script src="https://unpkg.com/nouislider@9.2.0"></script>
    <script src="https://unpkg.com/wnumb@1.1.0"></script>
    <link href="https://unpkg.com/nouislider@9.2.0/distribute/nouislider.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="./index.css">
</head>

<body>
    <div id="surveyElement"></div>
    <div id="surveyResult"></div>
    <script src="./index.js"></script>
</body>

</html>

#slider {
  margin-bottom:50px;
}

#slider .noUi-connect {
    background: #1ab394;
}

.btn-green {
  background-color: #1ab394;
  color: #fff;
  border-radius: 3px;
}

.btn-green:hover, .btn-green:focus {
    background-color: #18a689;
    color: #fff;
}

.panel-footer {
    text-align: right;
    background-color: #fff;
}