multiple choice -> text entry (hidden)

CathayaCathaya united statesCommunity Member Qubie ✭

multiple choice -> text entry (hidden)

How to achieve the beginning of the text entry is hidden, the text entry appears when the other option is selected,like this.

thanks a lot.

Best Answer

  • alfiaalfia India Qubie ✭
    edited May 28 Accepted Answer

    Hi @Cathaya,

    Use the below code to achieve this. Place the script in Qualtrics.SurveyEngine.addOnReady()

                    jQuery('input:text').hide();
    
        var rid =jQuery("input[type='text']").parent().parent().find("input[type='radio']").attr("id");
    
        jQuery("[type='radio']").change(function()
        {
    
            if(jQuery("[id='"+rid+"']").prop("checked") == true)
            {
                jQuery("[id*='"+rid+"~TEXT']").show();
            }
            else
            {
                jQuery("[id='"+rid+"~TEXT']").val('');
                jQuery("[id='"+rid+"~TEXT']").hide();
            }
    
        });
    

Answers

  • uhrxx005uhrxx005 Community Member Guru ✭✭
    edited May 28

    @Alfia, I would also love to do this, but the code doesn't appear to be doing anything when placed into the AddOnReady section. Any ideas how to fix it?

    EDIT: It worked under the "OnLoad"

  • alfiaalfia IndiaCommunity Member Qubie ✭

    @uhrxx005 said:
    @Alfia, I would also love to do this, but the code doesn't appear to be doing anything when placed into the AddOnReady section. Any ideas how to fix it?

    Thanks, I've updated the code, please check..

  • uhrxx005uhrxx005 Community Member Guru ✭✭

    What changed? I actually got it working fine when I moved it to the OnLoad instead of OnReady section

Sign In to Comment