Hello ,
I have a question about Piped Text:
I need to retrieve the value of question #1 (for example, a slider) and enter it into question #2 which is on the same page (before submit).
That is, every time the participant changes his answer in question #1 (for example, moves the slider) the value in question #2 needs to be updated.
How can I do it?
Thanks in advance!
Hi Maxim ,
I prefer to use below JS over piped text as it can update value dynamically.
I am assuming below structure/order of your question.
In Q25 , add below JS code to JS API of Qualtrics:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
/*Place your JavaScript here to run when the page is fully displayed*/
// Select the node that will be observed for mutations
let tex=document.getElementById("test");
const targetNode = document.getElementsByClassName("sliderToolTipBox"))0];
let observer = new MutationObserver(function() {
tex.innerText=Math.abs(targetNode.innerHTML);
targetNode.innerHTML =Math.abs(targetNode.innerHTML);
observer.disconnect(); // turn observer off;
observer.observe(targetNode, {
attributes: true,
childList: true, // observe direct children
subtree: true, // and lower descendants too
characterDataOldValue: true // pass old data to callback
});// turn back on
});
// observe everything except attributes
observer.observe(targetNode, {
attributes: true,
childList: true, // observe direct children
subtree: true, // and lower descendants too
characterDataOldValue: true // pass old data to callback
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Now in , Q25 add below HTML code in HTML section in Rich Document Editor :
Click to write the question text
Value to be updated
This span Value will where the data will be updated dynamically.
Below is the preview for the same:
Hope it resolves your Query!!!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.