How to add reset button in the Question | XM Community
Skip to main content

How to add reset button in the Question

  • November 30, 2022
  • 6 replies
  • 354 views

Forum|alt.badge.img+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

6 replies

Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+44
  • 1549 replies
  • November 30, 2022

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!


Forum|alt.badge.img+2
  • Author
  • 34 replies
  • November 30, 2022

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


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • December 1, 2022

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 = "";
        });
    };
});



Forum|alt.badge.img+2
  • Author
  • 34 replies
  • December 2, 2022

Thank you ahmedA!


Forum|alt.badge.img+2
  • Level 1 ●
  • 13 replies
  • September 14, 2024

Hi, how do I add this to a question? 

I want a button at the end of the question that resets/clears the answers.. 

 

Thank you


Forum|alt.badge.img+2
  • Level 1 ●
  • 13 replies
  • September 14, 2024

@ahmedA how do I add that code so that it shows a button in the question? Thank you!!!


Leave a Reply