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

How to add reset button in the Question

  • Nov 30, 2022 10:44 PM UTC
  • 6 replies
  • 462 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+48
  • Nov 30, 2022 11:29 PM UTC

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
  • Nov 30, 2022 11:42 PM UTC

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


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Dec 1, 2022 1:00 AM UTC

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
  • Dec 2, 2022 7:00 AM UTC

Thank you ahmedA!


Forum|alt.badge.img+2
  • Level 1 ●
  • Sep 14, 2024 1:45 PM UTC

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 ●
  • Sep 14, 2024 1:48 PM UTC

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