Search code examples
javascripthtmlqualtrics

How to Change value of lable in qualtrics?


I want to change the value of the question lable in qualtrics from the default to something else. Please see the code below:

<label for="QR~QID8" class="QuestionText BorderColor">Click to write the question text</label>
 <h2 class="noStyle">
 <label for="QR~QID8" class="QuestionText BorderColor">Click to write the question text </label>
 </h2>
 <div class="QuestionBody">
 <div class="ChoiceStructure"> 
 <input autocomplete="off" id="QR~QID8" value="" class="InputText QR-QID8 QWatchTimer" name="QR~QID8~TEXT" data-runtime-textvalue="runtime.Value" type="TEXT"> 
 </div></div> 

so when my user answers the previous question. the question should change from "Click to write the question text" the the previous answer . For example if user gives ABC as an answer. The new question text should be "ABC" rather than "Click to write the question text"


Solution

  • Found the answer.

    var label = document.querySelector('label[for="QR~QID8"]');
        label.textContent =document.getElementById('QR~QID2').value;