This is to send multiple choice question text into the text box of another question. I'm just gonna C&P his text here:
> It took me a day of work to figure this out, but I was able to better understand the object model Qualtrics uses for its questions so that I can get the text of a multiple choice question and send it to the text box of another question. I am worried I might loose it so I am pasting it below.
>
> The really hard part was finding where information is kept in their object model and getting to it. I needed to pass something called “element” to a function in order to get to the parts. It was a little easier if I used this.questionclick() in the Qualtrics javascript API, but that is fired when someone clicks anywhere on the question, not just when it is changed.
>
> Notes:
> 1) The questions are identified by the question IDs that Qualtrics gives them (ie QR~QID8). You can figure that out by using piped text in another question. The question ID comes out in the piped text (ie ${q://QID8/ChoiceGroup/SelectedChoices} ), you need to add the QR tilde in addition to the info you get from the piped text.
> 2) You can see the components of the element object when you pass element to the console log. I used chrome and then went to “more tools”, then “developer tools” (find them under the three dots in the upper right hand corner). Then I made sure that I could see console. The “element” object was then visible. The tough part initially was I could only see what I needed in the “this” object outside the function (I needed the items within the function I created) and could not figure out how to extract the part I needed (ask Catherine, she may be able to explain the “this” object, to be honest I am still working out how scoping of it works).
document.getElementById("QR~QID8").onchange = function(element){
//console.log(element); // use console to look at element to find what you need in the qustion;
var ele_var1=element.target.value.toString(); // gets selected option value from question;
var ele_var=element.currentTarget[ele_var1].Text; // gets text value of selected option;
document.getElementById("QR~QID6").value=ele_var; //updates text question;
}
Best answer by AnthonyR
View original