Dear all,
I am very new here in the forum and have not yet found an answer to my problem.
I would like to ask several questions in a matrix and I have already managed to get a slider (1-10). It would be great if I could still get two things done:
- When the question appears, the numbers (1-10 above the slider) should already be visible and not just the empty slider.
- If possible, there should be "not at all" in front of the slider and "very much" behind the slider. I have also tried the question type "multiple numeric input", but I didn't manage it.
This is the code I used for the slider:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
insertSlider (197354);
function insertSlider (qID) {
// Identify this question
var thisQuestion = $('#question'+qID);
thisQuestion.addClass('with-dropdown-sliders');
// Loop through all array drop-downs
$('select.multiflexiselect', thisQuestion).each(function(i, el){
var thisCell = $(el).closest('td');
// Hide the dropdown
$(el).hide();
// Some dropdown values
var currentVal = $(el).val();
var firstVal = Number($('option[value!=""]:first', el).attr('value'));
var secondVal = Number($('option[value!=""]:eq(1)', el).attr('value'));
var lastVal = Number($('option[value!=""]:last', el).attr('value'));
// Insert an input for the slider
var thisInput = $('<input class="inserted-input" type="text" />').insertAfter(el);
// Initiate the slider
thisInput.val(currentVal).bootstrapSlider({
'min': firstVal,
'max': lastVal,
'step': secondVal - firstVal,
'value': Number(currentVal),
'tooltip': 'always'
});
// Listener on the slider
$(thisInput).on('slideStop', function () {
if($('.tooltip', thisCell).is(':hidden')) {
$('.tooltip', thisCell).show();
$('.tooltip', thisCell).css('margin-left', '-'+($('.tooltip', thisCell).width()/2)+'px');
}
$(el).val($(thisInput).val());
});
// Hide the slider call-out if no value selected yet
if(currentVal == '') {
$('.tooltip', thisCell).hide();
}
});
}
});
</script>
<style type="text/css">.with-dropdown-sliders .slider.slider-horizontal {
margin: 1.5em auto 1em auto;
width: 90%;
}
.with-dropdown-sliders .slider.slider-horizontal .slider-handle {
margin-top: -5px;
}
@media(min-width: 769px){
.answertext{
text-align: left !important;
padding-left: 20px !important;
}
}
@media(max-width: 769px){
.answertext{
text-align: left !important;
padding-left: 0px !important;
font-size: 1 em !important;
}
.qnumcode.question-text{
font-size: 1.1 em;
text-align: center;
}
}
</style>
I would be very grateful for any help!