Forum Academy Marketplace Showcase Pricing Features

Randomizing Dropdown Selections

Hello. Had a quick question regarding randomizing values with dropdown menus.

I am attempting to make an online role-player. After the user creates an account, he/she will enter a page to basically “create” their character. Here’s how I want it to work:

First, the user will select a city.

Then, the user will pick a gender.

Once those two values are selected, I want to the drop down menu to randomize 20 names that the user can choose from. So for example if the user selected Houston and Male, I would like him to have an option of 20 American male names [first name & last name] to choose from.

Hopefully I was able to clearly explain what I’m trying to achieve. Hope someone can help me out!

You cna use a Dynamic choice in the drop down, ‘Do a search for’ wherever you are getting the names, and set the Sort to Random on the criteria panel.

Thanks for the advice, however that’s not exactly what I need assistance with.

To clear it up, I am trying to create a data sheet with let’s say 100 English male first names, 100 German male first names, 100 Spanish male first names, 100 English female first names, 100 English last names, etc…

Then, when the user selects the city and gender, there will be 20 randomly generated names. So the dropdown menu will take one out of the 100 English male first names and combine it with one out of the 100 English male last names to create a randomly generated full name. That name combination will then be deleted so that no other user may have the same name combination.

Hopefully this clears it up a bit more!

Ah, well, it is still roughly a long the lines of what I was saying all be it with some other things to consider.

For example, you do not want to ‘delete’ the final full name, because the individual component name parts could be used with other combinations, e.g. e.g Fred Smith, Fred Williams, Bill Smith, Bill Williams. What you should do is then store that final full name and then compare any future full names to see if it hasn’t already been created.

On your name source list you might have a structure;
Region, Gender, Element Type, Name
England, Male, First, Bill
England, Male, First, Steven
England, , Last, Smith
England, , Last, Porter
Denmark, Male, First, Soren
Denmark, , Last, Stig
America, Male, First, Randy
America, , Last, Kwoski

You would then do you usual for the search, e.g.
Do search for Name Element, criteria, Region = England, Geneder = Male, Element,= First Name Sort Random :first item join with Do Search for Name Element, region = America, Element = Last Name, Sort Random :first item

Last names are not typically gender specific, hence no need to specify the gender for generating that part of the name.

Then take that final output, generate a long text and store it in a ‘Used Names’ list. you can then check against the long names list if it has already been used on subsequent name generating.

Hope this gives you some ideas…

1 Like

I did everything you mentioned above, however I am still having a hard time combining the First Name and the Last Name as one selection.

After I input all criteria for [Do search for Name Element] I choose [:first item] like you suggested, however after that I am not given an option to choose [join with]. Here’s how my options look after inputing the [Do search for Name Element] :

I did play around and found the [join with] function available after I select ['s Name] rather than [:first item], however it creates an error…

I had a play as well, and this is harder than I initially thought…I did manage to get a randomized first name and second name into the same text box, but then I couldn’t do anything with it. I considered going down the route of custom javascripts to pull the value into another element/db, but that sort of defeats the purpose of Bubble.

Maybe need to throw this open to some of the others to see what they can come up with.

@NigelG, have you done this anywhere yet? merging together values to create a new concatenated value than can be used somewhere?

That is remarkably hard, isn’t it !

I can’t see it working well with either “on the fly” generated values (so by concatenation in a dropdown) or via a custom state.

Maybe you could pre-generate the list somehow ? API workflow ?

I generated a list of random first names, then in a RG cell added a text box, edited the text box to contain the current cell first name and next to it, in the dynamic editor added a call to search for a random selected last name, voila, Firstname Lastname. However, I couldn’t do anything with this text value. Couldn’t access it, could send it to a state or another object - nothing.

It seems such a simple operations made impossible!

Concatenating text by putting expressions side-by-side only works in the “large text” boxes, there are a couple around, one for example is in a boolean’s :formatted as text.

To use this, start with an expression that can become a yes/no value …
I’ll pick Website home URL to always get a string,
then is not empty to get a yes value.
Then :formatted as text gives us a large text box for the formatting fields.

Here it is giving its concatenated text into a custom state.

Of course, the big downside is that the resulting expression looks nothing like a text concatenation!

1 Like

That is a hell of a workaround!