User Tools

Site Tools


slidernumformat

This is an old revision of the document!


sliderNumFormat - Format slider scale and value numbers

The sliderNumFormat function formats scale numbers (above the sliders) and values (appear when you drag a slider). It allows scale and value formats to be the same or different. The function uses Intl.NumberFormat to format numbers in a variety of styles based on locale or locales. Some of the possibilities include:

  • Thousands separators (e.g., 1,000)
  • Decimals (e.g., 1,000.00)
  • Currency (e.g., $1,000)
  • Percents (e.g., 100%)
  • Units (e.g., 16 l, 16l, or 16 liters)
  • Scientific (e.g., 1.000E3)
  • Compact (e.g., $1K)

Here is a simple 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 sliderNumFormat 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 sliderNumFormat function JS:

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

Alternatively, paste the sliderNumFormat 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 sliderNumFormat function to apply it to the Slider question as follows:

Qualtrics.SurveyEngine.addOnload(function() {
	sliderNumFormat(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,{format:{style:"currency",currency:"USD",maximumFractionDigits:0}});
});

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

Options

format

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

Default: "en-US"

locale

locale is a string or array that specifies the locale or locales to be used by Intl.NumberFormat.

Default: "en-US"

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

slidernumformat.1724256791.txt.gz · Last modified: by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki