Use DropDown's Value as Number

I have list of numbers for distance like 10, 20, 30, 40 as part of dropdown list. Now I would like to use this numbers to as part of map data constraints apply search within range, but bubble is always considering dropdown list’s value as text and not providing way to convert it to number.

Is anyone has any clue to convert dropdown list’s value to number?

It’s best to create a database table containing a field with the data type being a number. Then use that table as the data source for the dropdown.

So when you’re using numbers as part of the map’s data constraints, simply use the dropdown’s value’s number.

Does this make sense?

1 Like

Actually my values in dropdown are as below:

10 Mile
20 Mile
50 Mile
Entire city

So practically I would like to truncate first two digits from dropdown value if value is not ‘Entire City’. Then I would like to convert it to number and use it for map constraint.

You’re thinking too hard about this. In the table I was talking about, just add another field that has a data type of TEXT. That text would be displayed in the dropdown as “10 Mile”, “20 Mile” etc.

Now for the Entire City option, add that item to the database table WITHOUT a number. Then you can use a condition in your map that goes something like this:

“When dropdown’s value’s number is empty …”

Got it?

1 Like

I got you idea.

Implemented it successfully.

Thanks for giving hint. But, I am still curious about data conversion from string to number which is very basic functionality.

1 Like

Glad to hear! And yeah, it’s an interesting premise. Maybe in the future, Bubble will implement something to make that easier.

Good luck with your project!
Daniel

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