Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Other specify issue with option to deselect response

I have the below script added to allow respondents to change their answer which works great.  This is necessary in some form as it is a long survey conducted by enumerators that might click on the wrong answer in a hurry and need to fix it.  Unfortunately,  the support team mentioned that "other specify" is not going to work due to this.  Indeed, some of my other specify responses are working and others are not.  I am not a coder so I am wondering if someone can help me figure out how to resolve this.  I have many questions with Other, specify but also want the enumerator to be able to correct a mistakely selected response.  Thanks!

<script>
$(document).ready(function(){
    var resps = {};
    $('input[type="radio"]').each(function(){
        var name = $(this).attr('name');
        resps[name] = SSI_GetValue(name);
    });
     
    SSI_CustomGraphicalRadiobox = function(graphical, input) {
        var name = input.name;
        var resp = SSI_GetValue(name);
        if (resp == resps[name]) {
            SSI_RadioReset(name);
            resp = 0;
        }
        resps[name] = resp;
    };
})
</script>
asked Jan 22 by sallen Bronze (905 points)
I've been fighting with trying to create a generic solution to this that will just work with graphical and non-graphical radio buttons, but it's proven quite hairy.  I'll have to give it another shot at a future point.  In the meantime, a half-baked solution might be to insert this after the "SSI_CustomGraphicalRadiobox" line:

var focus = $(document.activeElement);
if (focus.is('input') || focus.is('textarea')) {
    return;
}
Thanks, Zachary.  I somehow missed this on Friday.  Would the script then look like this?
<script>
$(document).ready(function(){
    var resps = {};
    $('input[type="radio"]').each(function(){
        var name = $(this).attr('name');
        if (!resps.hasOwnProperty(name)) {
            resps[name] = SSI_GetValue(name);
        }
    });
    
    SSI_CustomGraphicalRadiobox = function(graphical, input) {
        var focus = $(document.activeElement);
        if (focus.is('input') || focus.is('textarea')) {
        return;
        }
        var name = $(input).attr('name');
        var resp = SSI_GetValue(name);
        if (resp != 0 && resp == resps[name]) {
            SSI_RadioReset(name);
            resp = 0;
        }
        resps[name] = resp;
    };
})
</script>

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...