Question T694
Visible to All Users

bind a survey.data.x with radio button choices

created 7 years ago

how to bind survey.data.x array with choices ?

Comments (1)

    please some?

    Answers

    created 7 years ago

    Thanks Serge i found out the solution but can we make it dynamic like "choices": "{employers.name}" here the panel is the dynamic panel which bind the data with employers.name array ?

      Comments (1)

        No, choices can't be dynamic. You can only assign them.

        Thanks, Serge
        SurveyJS Team

        created 7 years ago

        ???

          Comments (1)

            According to the documentation https://surveyjs.io/Documentation/Library/?id=surveymodel#data
            the survey.data property is

            An object that stores the survey results/data. You may set it directly as { 'question name': questionValue, … }

            you can just write

            JavaScript
            survey.data.x = [ "item1", "item2" ]

            in case of "x" is a name of checkbox question

            You are talking about a radiogroup question. Radiogroup question can store only one choosen item:

            JavaScript
            survey.data.x = "item1";

            If you want to set an array of possible options for a radiogroup question (probably the https://surveyjs.answerdesk.io/ticket/details/t682 question), you should use the choices property (https://surveyjs.io/Documentation/Library/?id=questionradiogroupmodel#choices)) of a question, as illustrated in this sample - https://plnkr.co/edit/DpqFyFynZaOQEQLtFmA0?p=preview

            Thanks, Serge
            SurveyJS Team