How to add reset button in the Question | XM Community

How to add reset button in the Question

  • 30 November 2022
  • 4 replies
  • 191 views

Badge +2

Hi Community,
I'm trying to work with can add a reset/clear option to the survey that would like to clear their selections for the current question, they can simply press a reset/clear button and it would delete all the responses for that question at once


4 replies

Userlevel 7
Badge +36

ricsdpl
This would be quite difficult as for each question type a different JS would be needed it would make it more complicated.
My suggestion would be to don't go ahead with it as if at all you create that button and in future you change the question type you will have to change the button as well.
Hope it helps!

Badge +2

Hi Deepak, can you give me a sample reset/clear button for Side-by-side question

Userlevel 7
Badge +21

This should work for most questions:

Qualtrics.SurveyEngine.addOnReady(function () {
    const quest = this;
    const qc = quest.questionContainer;

    qc.querySelector(".QuestionText").insertAdjacentHTML("afterend", "");

    qc.querySelector(".reset").onclick = function () {
        qc.querySelectorAll(".q-checked").forEach((item) => {
            item.classList.remove("q-checked");
        });
        qc.querySelectorAll("select").forEach((item) => {
            item.clear();
        });
        qc.querySelectorAll(".InputText").forEach((item) => {
            item.value = "";
        });
    };
});


Badge +2

Thank you ahmedA!

Leave a Reply