Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showOtherItem value selection #5983

Open
stephenstroud opened this issue Oct 23, 2024 · 1 comment
Open

showOtherItem value selection #5983

stephenstroud opened this issue Oct 23, 2024 · 1 comment

Comments

@stephenstroud
Copy link

stephenstroud commented Oct 23, 2024

How can I customise the default value of other. My other values are represented by integer value however, other appears as the string "other". I want to assign an int value to other before it goes down to the server?

image

Data response with Other selected

image

@stephenstroud
Copy link
Author

stephenstroud commented Oct 23, 2024

I tried the below but it breaks as 35 doesn't exist and I don't want to add other to the list if showOtherItem is set.

survey.onValueChanged.add(function (sender, options) {
  
     if (options.name === "EmploymentSector") {

       const question = sender.getQuestionByName("EmploymentSector");       
       if (question ['isOtherSelected']) {          
         // When "Other" is selected, set the value to 35
         question .value = 35;
       }
     }
   }); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant