Get a slider value and write in the question | XM Community
Skip to main content
Question

Get a slider value and write in the question

  • November 21, 2019
  • 5 replies
  • 207 views

Hi everyone, I want to get a value from the slider and write that down in the question I don't know but it is not working Could someone help me? ========================================================= Qualtrics.SurveyEngine.addOnReady(function() { var val = jQuery("#QID58\\~1\\~true-result").slider("option", "value"); document.getElementById("upload1").innerHTML = val }); =================================== Then use span function in the main html text Thank you so much in advance

5 replies

ClairJ
Level 4 ●●●●
Forum|alt.badge.img+15
  • Level 4 ●●●●
  • November 22, 2019
Hi @emabed could you not just do this with piped text, rather than custom code?

ana_velez
QPN Level 5 ●●●●●
Forum|alt.badge.img+27
  • QPN Level 5 ●●●●●
  • February 18, 2020
I was thinking on the same. you can do this with piped text using the question selected choices

  • September 28, 2020

https://www.qualtrics.com/community/discussion/comment/20000#Comment_20000Hello Clair,

how does one achieve this with a piped text?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • September 28, 2020

You can't pipe the value until the page after the slider. I'm assuming you want the slider value in question text of the slider question. Two things:

  1. The first line of your JS wrong. You need to double escape ~. There really isn't any need to hard code QID numbers. Also, there is not a jQuery slider function (unless you are using a jQuery ui slider - which a Qualtrics slider isn't). The correct JS would be:
     jQuery("#"+this.questionId+" .ResultsInput").val();

  2. Even if your JS were correct, you would only be displaying the initial value of the slider when the page loads. You need to use a MutationObserver to update the value each time the slider value updates.


ClairJ
Level 4 ●●●●
Forum|alt.badge.img+15
  • Level 4 ●●●●
  • September 28, 2020