Forum Academy Marketplace Showcase Pricing Features

Replace number with Text

I have text box that gives me the max value between two dropdowns (1,2,3,4,5,6). However, I now need to convert the resulting number into text so that I can see the size instead of the number (i.e. 1=XS, 2=S, 3=M, 4=L, 5=XL, 6=XXL).

What would be the best way to do this. I can’t seem to figure it out.

You could add 6 conditions on that text. When dropdown’s value is 1 > change text to XS, etc.

The problem is that I need to convert the Max value returned of the two dropdowns to become the letter so it won’t let me create a condition. For example, dropdown A = 1 and dropdown B = 2. So the text field returns a value of 2. But I now need the text field (or another field) take the resulting 2 and return “S”.

BTW, I saw your website. Very nice. For the app I’m building for a client, they want to restrict access to only a select group of users. Each user (about 10) would need to be setup by their admin and given a specific password. When a user opens the URL of the app, they would need to see a popup that asks them to enter one of the 10 email/password combinations before they could go any further.

Someone in the forum suggested that I build out an admin page where that is generated. From there, I can either input valid email addresses that can register or create the accounts yourself using “Create account for someone else”.

Is this something you could coach me through?

How about …

Alternative 1 Gaby’s suggestion

Alternative 2 Six conditional workflow actions to set a size in a custom state.

Alternative 3 Start with a list of sizes, then use the max of the values as an index to the list.

Bubble won’t let you do any more numerical operations past the first number parameter of list#item, so the max value would need to be stored elsewhere first, for example in a custom state that is updated on either of the dropdowns changing value.

Then the problem becomes: how to generate a list of sizes.

This could be a database table - appropriate if they can be changed at times.

Or it could be a text list in a custom state, converted to a list with :extract with Regex .

You can probably see this working, but getting messy for such a small list.

Alternative 4 Using the Expression element in the Toolbox:

["XS","S","M","L","XL","XXL"][dropdown 1's value <max>dropdown 2's value - 1]

Then you can refer to the Expression’s value for the size “S”.

If you go for this option, there’s an enhancement to cope with empty selections if you need it.

Alternative 5: after doing the max, you can format as number, which converts the number to text.
Then apply six :find & replace operations to change 1 to XS, 2 to S, etc.

Hi mishav. It took some time but I applied your Alternative 5 and got it to work. I had to figure out that I just needed 6 :find & replace expressions after the max calculation. But it works. I owe you a coffee! Thanks again!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.