Question T10887
Visible to All Users

open datepicker on click of checkbox

created 2 years ago

Hi,
i am looking for a datepicker option displays after we select choices given in checkbox. i am trying to do this by code given below. please resolve it or give any suggestion.
Thankyou

Answers approved by surveyjs Support

created 2 years ago

Hello,

You can add a datepicker question that will be visible by a condition. Condition visibility demo can be found here - https://surveyjs.io/form-library/examples/condition-kids
If you are looking for the datepicker custom widget, the corresponding demo is - https://surveyjs.io/form-library/examples/custom-widget-datepicker/

Thanks, Serge
SurveyJS Team

    Comments (2)

      i am using this JSON but this not working…

      Code
      {       name: "Card 1",       elements: [         {           type: "checkbox",           name: "symptoms",           title: "Do you have any of the following symptoms?",           isRequired: true,           description: "Choose as many as you like",           choices: [             {               value: "Fever",               text: "Fever",             },             {               value: "Cough",               text: "Cough",             },             {               value: "Shortness of Breath",               text: "Shortness of Breath",             },             {               value:                 "Contact with covid-19 positive patient in the last 14 days",               text: "Contact with covid-19 positive patient in the last 14 days",             },             {               value: "Travel outside the country in the last 14 days",               text: "Travel outside the country in the last 14 days",             },             {               value: "Are you Covid Test Positive",               text: "Are you Covid Test Positive"             },           ],           hasNone: true,           otherText: "None",         },         {           "type": "text",           "name": "covidDate",           "title": `{ default: "Date", sp: "SP_Date" }`,           "visibleIf": "{symptoms}='Fever'",           "isRequired": false,           startWithNewLine: true,         },       ],     },

        Hello Kartik,
        Thank you for the update. Please update the visibleIf expression and use the contains operator instead of the equality operator =:

        JSON
        ... "visibleIf": "{symptoms} contains 'Fever'", ...

        The updated example.

        For more information on how to build conditional expressions, refer to: Conditional Logic and Dynamic Texts.

        Let us know if you have further questions.