Have an idea?

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

how to un-select a radio button or checkbox when text is removed from textbox.

Hai Guys,
I have a question, in my survey where the other is asked with a radio button or checkbox, linked with text box to enter there response. when user enter the text it will be automatically selected but when user is removing the text the checkbox/radio button should be automatically deselected.
asked Sep 27, 2019 by joey (130 points)
The behaviour you refer to is the default nature of the "other specify" text box feature.

Are you doing something different?

Maybe this feature within the Question Library will gain your interest too?

https://www.sawtoothsoftware.com/community-question-library/1747-not-applicable-per-question
yes, by default it will be selected.

1 Answer

+2 votes
Please try adding this script to your select question:

<script>
$(document).on('keyup', '#[% QuestionName() %]_div input[type=text], #[% QuestionName() %]_div textarea', function(){
    if (!$(this).val()) {
        var checkbox = $(this).closest('.clickable').find('input[type=checkbox]');
        if ($(checkbox).length) {
            SSI_SetSelect($(checkbox).attr('id'), false);
        }
        else {
            SSI_RadioReset('[% QuestionName() %]');
        }
    }
})
</script>
answered Sep 27, 2019 by Zachary Platinum Sawtooth Software, Inc. (143,925 points)
Hi Zachary, would there be a valid reason why this script would be needed when default behaviour does operate like this already? Thanks Paul.
Lighthouse automatically selects radio buttons and checkboxes when the other specify is typed into, but doesn't automatically deselect the radio button or checkbox when the other specify is cleared out.  Is that not what you're seeing?
OK, got it. Thanks Zachary.
Thank you, Zachary for your code and the code working fine.
thank you  Zachary its workingâ˜ș
...