- Posts: 26
- Thank you received: 2
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify elements var thisQuestion = $('#question{QID}'); var thisInput = $('input:text', thisQuestion); var sliderQuestion = $('.numeric-multi:eq(0)'); var sliderInput = $('input:text', sliderQuestion); $(sliderInput).on('slideEnabled',function(){ // Listener on slider $(this).on('slide slideStop', function(event) { // Load the numeric input $(thisInput).val($(this).val()); }); }); }); </script>
var sliderQuestion= $('.numeric-multi:eq(0)');
Close - that selector targets slider questions, not the actual sliders.eq(0) is the first slider, eq(1) the second and so on
var sliderInput = $('.answer-item.slider-item:eq(0) input:text');
<script type="text/javascript" data-author="Tony Partner"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify elements var thisQuestion = $('#question{QID}'); var thisInput = $('input:text', thisQuestion); var sliderInput = $('.answer-item.slider-item:eq(0) input:text'); $(sliderInput).on('slideEnabled',function(){ // Listener on slider $(this).on('slide slideStop', function(event) { // Load the numeric input if value is >= 0 if($(this).val() >= 0) { $(thisInput).val($(this).val()).trigger('keyup'); } else { $(thisInput).val('').trigger('keyup'); } }); }); }); </script>