Withdraw Button 2023 issue | XM Community
Skip to main content

We have been using javascript for our withdraw button in our surveys (See below line for script). This script is no longer working as of September 2023. Originally, when the withdraw button was clicked, it would first ask “Are you sure you want to withdraw?” and then proceed to follow the branch logic set up in our survey flow. Now, when the withdraw button is clicked it brings us back to the beginning of the survey after asking “Are you sure you want to withdraw?” when it should be leading to a set of questions, as per our branch logic in survey flow, which works in tandem with this code. It is no longer possible for participants to get sent to the end of survey. We have tried other methods posted in the forums and none of them have worked.

As such, we would like to use a new code/updated code so that we can maintain our withdraw button, since qualtrics does not provide a function for that. 

Any advice and guidance, or updates to the code below would be extremely helpful. 
 


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><script>

var inject_me = function() {

    if (!$("#NextButton").length) {

        window.requestAnimationFrame(inject_me());

    } else {

        var element = document.getElementById('toggle');

        if (typeof(element) != 'undefined' && element != null) {

            document.getElementById('ProgressBar').style.display = "none";

        } else {

            function addParameterToURL(param) {

                _url = location.href;

                _url += (_url.split('?')f1] ? '&' : '?') + param;

                return _url;

            }

            newURL = addParameterToURL("withdraw=true");

            var withdraw = "<a href=\"" + newURL + "\" onclick=\"javascript:return confirm('Are you sure you want to withdraw?')\" class=confirm id='WithdrawLink'><span class='ButtonLeft'></span><span class='WithdrawButton Button' id='WithdrawButton'>WITHDRAW</span><span class='Button' style='float:left !important'></span></a> &nbsp; &nbsp;"

            var buttonsDiv = document.getElementById("Buttons");

            buttonsDiv.innerHTML = withdraw + buttonsDiv.innerHTML;

        }

        if (document.getElementsByClassName("EndOfSurvey").length) {

            document.getElementById('Withdraw').style.display = "none";

            document.getElementById('ProgressBar').style.display = "none";

        }

        if (document.getElementsByClassName("SurveyError").length) {

            document.getElementById('Withdraw').style.display = "none";

        }

    }

};

inject_me();

</script>

Be the first to reply!

Leave a Reply