Selecting all options by default in a select_multiple question

Hi All,

I'm having trouble with something. I have a select_multiple field and I want all values in the answer options to be automatically selected by default. In my form, the number of answer options will vary based on their previous selection because there is a choice-filter on this question, so I cannot dictate, for example, that options 1, 2, and 3 should always be selected. Rather, I need to make sure ALL of them are.

Does anyone have a sample form on this?

Welcome to the ODK forum, @SJ! We're glad you're here. When you get a chance, please introduce yourself on this forum thread. I'd also encourage you to add a picture as your avatar because it helps build community!

This sounds like a curious use case, can you share the questions you are asking?

Hello,

Thanks for the kind welcome :slight_smile:

The current form I'm working on looks something like this:

  1. Please select your district
  2. Please select your town (choice-filtered by district)
  3. Please select your neighborhood (choice-filtered by town)

Now I want to display a select_multiple question with all the neighborhoods, and I want all options to be selected by default.

Is this possible?

Just to make sure I understand - question # 3 is a select_one, and then you want a 4th question that has the same filtered choices as # 3 but is a select_multiple and has all of the choices selected by default?

Ah sorry let me rephrase. Question 3 should be a select_multiple list of neighborhoods, choice-filtered by question 2 (town). Questions 1 and 2 would be select_one. And in question 3, all options should be selected by default.

It might be difficult to achieve... could you please attach a sample form (as simple as possible) so that we can play with it?

Hi. I realize I may have been including too much unnecessary information. All I want to do is to have a select_multiple question in which all options are selected by default, instead of de-selected by default. Is there any way to achieve this?

1 Like

Yes but it is important to know if your choices are dynamic or static. There is no way to ask the app to select all options no matter what they are so selecting all of them with the first (dynamic) version is something that might be difficult to achieve.

Ah ok noted.
test.xlsx (14.1 KB)

I have attached a test form above. It's the field called "recamp" that I want to apply this to. Thank you all for trying to help with this.

If it was a static list of options without choice_filter then it would be easy you would just need to list all the possible options in default column.
In your case however it is still doable but more difficult. To achieve that you have to calculate that list of possible options. I have a sample form:
SelectAll.xlsx (6.3 KB)
In your case the if statement might be much more complex but still you should be able to do that. If you have any problems with building it let us know.

Thanks @Grzesiek2010 really helpful.

A small point to add in case somebody makes the same mistake that I just made. If you list all options under default and include a choice_filter this works fine in Enketo and all relevant options will be selected but it doesn't work in Collect

2 Likes