Question T6011
Visible to All Users

Hide question for single checkbox question

created 4 years ago

I want to disable questions based on anonymous or not. So the idea is to show a question 'name' and 'email'. Then I show a checkbox question with a single choice 'anonymous'.

How can I remove the question from this checkbox?

Code
{                             type'panel',                             name: 'introduction_panel',                             elements: [                                 {                                     type: 'text',                                     name: 'contact_name',                                     title: strWhatIsYourName,                                     hideNumber: true,                                     isRequired: true,                                     visibleIf: '{contact_is_anonymous} empty'                                 },                                 {                                     type'text',                                     inputType: 'email',                                     name: 'contact_email',                                     title: strWhatIsYourEmail,                                     isRequired: true,                                     hideNumber: true,                                     visibleIf: '{contact_is_anonymous} empty'                                 },                                 {                                     type'checkbox',                                     name: 'contact_is_anonymous',                                     hideNumber: true,                                     choices: [                                         {                                             value: 'true',                                             text: strAnonymous                                         }                                     ]                                 }                             ]                         }

Answers approved by surveyjs Support

created 4 years ago

Hello,

You need to set the titleLocation to the hidden value:

JSON
{ "type": "checkbox", "name": "contact_is_anonymous", "titleLocation": "hidden", "choices": [ "true" ] }

Thanks, Serge
SurveyJS Team

    created 4 years ago

    Hello Edgar,
    There are two ways.

    1. You can use choicesVisibleIf, as: choicesVisibleIf: "{contact_is_anonymous} empty and {item} = 'x'". You can use a custom function where you can pass parameters, {contact_is_anonymous}  and {item}.
    2. You can use visibleIf for choice item itself:
    JavaScript
    choices: [ { value: 'true', text: strAnonymous, visibleIf: '{contact_is_anonymous} empty' } ]

    Thank you,
    Andrew
    SurveyJS Team

      Comments (1)

        Hi Andrew

        Sorry, I think I wasn't clear enough.

        Right now for the check box you get:
        Clipboard-File-2.png

        What I want to achieve is hide the question text of the checkbox which inb the screenshot is 'contact_is_anonymous'. So just show the checkbox, nothing else of that question.