- Posts: 7
- Thank you received: 2
Ask the community, share ideas, and connect with other LimeSurvey users!
function changeOtherSliderValue() { $(document).ready(function() { //listen for a change in any hidden field $('input:hidden').change(function() { //if the hidden field is part of a Multiple-Numeric question, take action if ($('.numeric-multi').length > 0) { //get questionID var thisQuestion = $('.numeric-multi').attr('id'); //get triggering hidden input field ID var thisHiddenID = $(this).attr('id'); //get entered value var thisSliderValue = $(this).val(); //calculate the new value for the other slider (total = 5) var otherSliderValue = 5 - thisSliderValue; //split the hidden input ID to know which option was changed by user var thisOption = thisHiddenID.split('SQ'); var thisOptionID = thisOption[1]; //build target IDs for both Hidden Input and Slider Text Input var targetHiddenID = '#' + thisOption[0] + 'SQ'; var targetSliderID = '#slider_' + thisOption[0] + 'SQ'; //add appropriate option for the target if (thisOptionID == '001') { //target is 002 targetHiddenID += '002'; targetSliderID += '002'; } else { //target is 001 targetHiddenID += '001'; targetSliderID += '001'; } //call function to move target slider and update input values $(thisQuestion).matchSliders(otherSliderValue,targetHiddenID,targetSliderID); } }); }); } (function( $ ){ $.fn.matchSliders = function(val,targetHiddenID,targetSliderID) { //move the target slider $(targetSliderID).bootstrapSlider('setValue',val); //store the value in both hidden and text inputs $(targetSliderID).val(val); $(targetHiddenID).attr('value',val); //decide if Next button needs to be activated disableQNext(); }; })( jQuery );
var inputs = $(':input[type="text"]', thisRow); inputs.each(function(j){ $(this).attr("value", "5.5555").attr("data-value", "5.5555"); });