Deselecting a checkbox on retake link | XM Community
Skip to main content
Solved

Deselecting a checkbox on retake link


courtrc
Level 3 ●●●
Forum|alt.badge.img+9

I’ve built an Official Complaint Form for my Compliance team and built it so they could enter initial complaint details, then with retake links, update the response and with the update ticket task, update the corresponding ticket data.

 

On the first submission they have a date field with Flatpickr to select a date.

First submission

On second submission, they can edit the dates previously entered. So I’m using display logic to show an additional question for each date which pipes in the previously selected date and where they can select a checkbox to edit the date. That checkbox displays the question with the calendar picker again to overwrite the previously selected date.

Default second submission

 

Second submission with edit checkbox selected

One piece that’s “working as intended”, but not the ideal user experience I’d like is that on a retake link, revisiting the survey preserves the answers to questions, which means, if I wanted to go in a third time to edit something, that checkbox will still be selected and while I think I’ve built survey flow logic to prevent it from storing the placeholder date when it’s not being edited, it’s still weird to see the checkbox checked with the placeholder date if it’s not being edited in that submission (below). 

Third submission preserved how second submission was submitted

I did attempt to include some JavaScript to attempt to deselect that checkbox upon page load within that checkbox question targeting that question ID, and it did… nothing.

Qualtrics.SurveyEngine.addOnload(function()
{
        jQuery('input[type="checkbox"]').change(function(){
            if (jQuery("#QID38").is(":checked")) { // If checkbox is checked
                jQuery("#QID38").prop("checked", false); // Deselect the checkbox
            }
        });

});

So I don’t know if I’ve set something up incorrectly or if it’s just not possible to overwrite and deselect that checkbox. But if there is a way I’d love to hear it! 

If I can’t solve for this my workaround will be to tell the Compliance team to deselect the checkboxes on any submission they’re still checked, then on future retakes they’ll remain deselected, but that is not a good user experience. Thanks in advance!

Best answer by vgayraud

Hi,

Try this

Qualtrics.SurveyEngine.addOnload(function () {

  const choices = this.getChoices();
  const checkbox = document.querySelector('#question-' + this.questionId + ' input[type="checkbox"]');
  if (checkbox && checkbox.checked) {
    this.setChoiceValue(choices[0], false);
  }
});

 

View original

2 replies

vgayraud
QPN Level 6 ●●●●●●
Forum|alt.badge.img+49
  • QPN Level 6 ●●●●●●
  • 389 replies
  • Answer
  • April 1, 2025

Hi,

Try this

Qualtrics.SurveyEngine.addOnload(function () {

  const choices = this.getChoices();
  const checkbox = document.querySelector('#question-' + this.questionId + ' input[type="checkbox"]');
  if (checkbox && checkbox.checked) {
    this.setChoiceValue(choices[0], false);
  }
});

 


courtrc
Level 3 ●●●
Forum|alt.badge.img+9
  • Author
  • Level 3 ●●●
  • 55 replies
  • April 1, 2025

@vgayraud this worked fabulously! Thank you so much! Appreciate the help.


Leave a Reply