Hello,
Is it possible that whenever we use select_one, we can make the first choice in the list selected by default?
The only option is to use default and put there your first option in each question but that's it there is no an easy way to select the first option automatically.
Okay, I cant use the "default" approach because the options in the select_one depend on what was chosen in a previous select_one.
Thank you for the quick replies!
You can use the calculate column. For example, ${q1} in calculate column in select_one question will select the value of the q1 variables, from the choice list. Let me know if this makes sense.
Doing this gives this error:
The error in dependency cycle means that you are using the same variable in the calculate expression, where you are adding the calculation. Can you send the file, or paste here the calculation as well as the variable names?
For example i have a select_one named "fruit" and i want that its first choice (whatever it is) is selected by default. I have kept the name for this select_one type as "fruit" as well.
Challenge accepted!
Sorry, I am probably not getting the problem clearly. So, if the first choice of "fruit" is static, that is easy - you can simply put the value of the first option in calculate column. If the choice list is filtered based on a previous response, you can try using if statements. For example, if the choice list for "fruit" is filtered based on "season" field, you can try if(${season}=1, '1',if(${season}=2,'5','10')). This will select 1 (which is the first fruit) if season is 1. It will select 5 (assuming 1, 2, 3 and 4 are for season 1, and 5, 6, 7, 8 and 9 for season 2) if season 2 is selected. It will select 10 if season is not 1 or 2 (say, 3). Let me know if this makes sense.
Ah. So you want to preselect a default option, which is (already) the result of a choice_filter. Hmmm... Lemme cogitate on that and get back to you.
@Xiphware @Mehrab_Ali I am attaching a screenshot example for your reference.
The values displayed of both fruit and vegetable depend on which season has been selected. Hence, both the lists depend on the previous answer.
@Mehrab_Ali where do i put the if statements? In the calculation column?
Yes, in the calculation column.
It works!
forum.xlsx (9.8 KB)
However, I have around 400-500 values of 'season' and writing an if statement for all of them will be tedious, is this the only solution?
I am not sure, but you can try playing with pulldata and a csv file with seasons and fruit names. In the same way, use pulldata in the calculate column.