Thomas Gibbons Consulting Qualtrics Wiki

Contact TomG on Qualtrics Community

User Tools

Site Tools


mfcssliders

mfCsSliders - Mobile-friendly Constant Sum Sliders

The mfCsSliders function converts a Qualtrics Slider question into a Mobile-friendly constant sum slider question. This function was created because Qualtrics constant sum sliders are NOT mobile-friendly.

Functionality includes:

  • Optionally turn “must total” on or off
  • Set “must total” to any amount
  • Dynamic total calculation with visual indicators when equal to or over “must total” amount
  • Supports addition of prefixes or suffixes to numeric values (%, $, etc.)
  • Supports formatting of scale style

Example:

This function is available for a reasonable fee. Contact TomG on the Qualtrics Community to learn more.

Set-up Instructions

Add Function To Survey

Add the mfCsSliders function to the survey header to make it available to any question in the survey. Go to Look & Feel → General → Header edit → and paste the provided mfCsSliders function JS:

<script>/*Paste mfCsSliders function JS here*/</script>

Alternatively, paste the mfCsSliders function JS into a question's JS outside the existing Qualtrics functions to make it available to questions on the page.

JavaScript Function Call

Add JS to call the mfCsSliders function to apply it to the Slider question as follows:

Qualtrics.SurveyEngine.addOnload(function() {
	mfCsSliders(this);
});

To override the default options, specify the desired options in the second function argument as an object. For example:

Qualtrics.SurveyEngine.addOnload(function() {
	mfCsSliders(this,{mustTotalFlag:false});
});

Question Settings

  • Slider question
  • Type: Sliders
  • Custom Start Position: Off
  • Scale Points: 0 to 100 (or some other max)
  • Show value: Off
  • Mobile friendly: On

Custom Validation

If mustTotalFlag is true, then custom validation should be added. One validation condition is needed - the first slider should equal the mustTotalAmt minus remaining sliders. Use a math expression to the right of the “Is Equal to” condition something like:

$e{ 100 - q://QID1/ChoiceNumericEntryValue/2 - q://QID1/ChoiceNumericEntryValue/3 }

When the rows of the slider are conditional through the use of carry forward or display logic, it may be necessary to use a hidden text entry question immediately after the slider question and base the slider custom validation on that question. The following code can be used to update the text entry question with the slider total:

Qualtrics.SurveyEngine.addOnload(function() {
	mfCsSliders(this);
	var q = jQuery("#"+this.questionId);
	Qualtrics.SurveyEngine.addOnPageSubmit(function() {
		var sum = 0;
		q.find(".ResultsInput").each(function() { sum += Number(this.value) });
		q.nextAll(".QuestionOuter:first").find(".InputText").val(sum);
	});
});

Options

labelStyle

labelStyle is an object that specifies css style of the scale labels.

Default: {"font-weight":"bold"}

mustTotalAmt

mustTotalAmt is a numeric value that specifies what the constant sum must total to when mustTotalFlag is true.

Default: 100

mustTotalFlag

mustTotalFlag is a boolean that specifies if the constant sum must total to a specific value.

Default: true

prefix

prefix is text that is shown before numeric values.

Default: ""

suffix

suffix is text that is show after numeric values.

Default: "%"

widths

widths is the width of the constant sum numbers in ems. An 'em' is the width of a wide character (i.e., M).

Default: 3

Qualtrics Wiki

mfcssliders.txt · Last modified: 2023/03/09 11:01 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki