Select to view content in your preferred language

Designing a survey with random fields from a list

687
6
12-13-2023 12:49 PM
giossss
New Contributor

Hi, everyone, I have a question: I need to develop a form with 18 fields in the select_one format. However, I don't want these fields to appear every time the form is filled out. Instead, I want 7 random fields from this group of 18 to appear with each new entry. Is it possible to create a form in this format?

0 Kudos
6 Replies
abureaux
MVP Frequent Contributor

Probably easiest with JS.

You'd need something like this: https://stackoverflow.com/questions/18806210/generating-non-repeating-random-numbers-in-js

Once you have your 7 random numbers, the rest is easy. Just use choice_list, and assign a static number to each select_one answer. E.g., Each time "4" is chosen, item #4 in your select_one list will be visible.

Not exactly the easiest thing to do, but theoretically possible.

0 Kudos
DougBrowning
MVP Esteemed Contributor

How about this idea.

Use format-date(now(), '%S') to get a string of seconds.  Can convert to int or leave as string.

then base the relevant for the fields on what the seconds are.  So it should be random based off whatever the current time of day is.

Relevant could be something like if(seconds > 0 and < 3, show, dont) then just vary the seconds for each question.

Just a crazy idea.

abureaux
MVP Frequent Contributor

I like! It's essentially the same thing as the JS I proposed, but soooo much less work.

@giossssjust don't forget that 60 / 18 = 3.33333, so one of your questions will have a range greater than 3.

DougBrowning
MVP Esteemed Contributor

Yea I thought of that.  Would mod 18 do it?

BrianTruong
Emerging Contributor

Hey Doug, 

 

Your link on my question earlier today led me here. Which column would you input "format-date(now(), '%S')" in?

 

Thanks,

0 Kudos
DougBrowning
MVP Esteemed Contributor

Create a special field for this then use that field in The relevant with diff seconds.  That way it will random show it.

0 Kudos