Q1: choices : Not at all Likely, Likely
I want to pipe answer choices in next question which will be on same page with answer choices in lower case.
This can be put in place by using JavaScript to update an HTML element on the same page. In the 2nd question, use the Rich Content Editor's HTML/Source view "<>" to update the Question Text with the below:
Click to write the question text<br>
<br>
Answer: <span id="answer"> </span>
Then in the 1st question which is a single select Multiple Choice, add the below to the question's JavaScript in the OnReady section. When the question is clicked, it gets the choice value which is then used to get the choice text. This is then turned to lowercase and used to update the "answer" element in the 2nd question.
var qid = this.questionId;
this.questionclick = function(event,element) {
var selChoice = this.getSelectedChoices();
var choiceRef = "#"+qid+"-"+selChoice+"-label > span";
var choiceText = document.querySelector(choiceRef).innerHTML;
choiceText = choiceText.toLowerCase();
document.getElementById("answer").innerHTML=choiceText;
}
Add below HTML in second question for piping runtime text.
<span id="pipedText"> </span>
add below callback function based jQuery code in first question’s javascript.
this.questionclick = function(event,element){
var valX=parseInt(this.getSelectedChoices(),10)-1;
var iDX= "#"+this.questionId+" .ChoiceStructure li:eq("+valX+")";
var XVAL=jQuery(iDX +" label span").html();
jQuery("#pipedText").text(XVAL);
}
I just checked, this one is too old query. Why is it reopened?
Hi
Thank you for your previous answers here. I would love to do something similar but for the total sum of sliders from a constant sum question rather than a multiple choice question. What would be the appropriate Javascript code here?
For context:
I have a constant sum slider question with three rows. I want respondents to either move the sliders until the sum is 100 or skip the question. Adding the “Must total” validation is useful as it helps respondents add up the sliders to 100, however, it forces respondents to answer the question as they cannot move to the next question unless the sliders sum to 100. I am worried this will hurt data quality if respondents aren’t sure about the answer to this question and randomly put one of the sliders to 100 to move onto the next question. Thus, I have coded up a custom validation that allows respondents to move onto the next question if the sliders add up to 100 or they click a button below the sliders that says “I am not able to answer this question” (and displays an error otherwise). However, I would still like to help respondents with the math if they are capable of answering the question. I’d love to have the total sum dynamically displayed below the sliders so respondents can more easily set the sliders to sum to 100.
Thank you in advance for your advice and help!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.