Conditional dropdowns

Hi, I’m new to bubble and I’m having some issues understanding the database.
I have 2 dropdowns that reference the same data group.

I have 2 dropdowns that successfully search the data group, here is the header and some sample data.

Product | Interval | Type

Grass | 1 week | subscription
Grass | 2 weeks | subscription
Starter Kit White | one-off | product
Starter Kit Black | one-off | product

If someone selects grass in the first dropdown, the second dropdown will show 1 week and 2 weeks in the dropdown (I’ve successfully done this)

BUT

I want to be able to hide the second dropdown if the “Type” is not “subscription”
I haven’t been able to workout how I can determine the visibility of the second dropdown by relating back to the database based on a field related to the first choice dropdown without me having to tell the second dropdown to hide if the first dropdown contains “starter kit”. This works but I have a lot more data and want he visibility to be based on a related field in the same row of the data.


You can reference to the type of the selection i.e first dropdown products’ type is “product” which is more general than referring to product name which is specific

The correct way to do this not through the database, it is through the use of conditionals on the drop down element itself as you seem to be aware.

Your conditional should ready something like “when dropdown #1 value-subscription is Yes”

If you have not set up your database correctly then it won’t work. Your database should have a datatype with a datafield of subscription Yes/NO…

Hi koechamos51 and boston85719,

Thanks, both for your replies, I really appreciate it.
I totally understand what both of you are saying and I know that’s what I need to achieve but I just don’t see the option to say that the “type” = “product” or refer to another value in the dropdown 1.

Maybe I’m missing something…see attached

Morgan

The reason I didn’t want to use the yes/no and reference a field type is because I have more than 2 types but I only want to show when there is a subscription. But perhaps I need a yes/no field in the database to use type?

yes the issue is how you have your database setup

Datatype = Product
Datafield = is_subscription (Yes/NO)

Then have whatever other datafields you want

your conditional is
WhenSelectProduct’svalue is_subsciption = no

Then make the element not visible if you are trying to hide it when the first dropdowns product type is not a subscription

or

your conditional is
WhenSelectProduct’svalue is_subsciption = yes

to make the second drop down not visible when the first drop down product is a subscription

1 Like

Thank you. It turns out the dropdown was a text item and when I changed it to product type all the answers above worked. Appreciate your time.

Just make sure you get comfortable with datatypes and data fields and the relationship between them. Important to understand a bit of database design, especially surrounding the “many to many” relationships in relational databases.

When I first started out on bubble I had no previous experience in web development and I found other resources to learn about key components like database design, user experience design and user interface design very helpful in my development processes; especially database design.

One of the things that I began to understand about database design and relationships which improved everything was the idea that one data type could be the data field in another ( the relationship ) which enabled me to call up data efficiently; like a string the data types become connected.

This also helps with the idea of categories and sub categories where you don’t actually need to have two separate data tables of category and sub category and instead could use the relationship where there is a data type of category and it has a data field which is “category” ( this is pointing at the same data type )…doing something like this gives ability for almost infinite combinations of category and subcategory plus could add sub subcategory.

Hi @morgan
I am also building a 2 dropdown feature. But I am not able to show only “1 week” and “2 weeks” option in the 2nd dropdown when the user selects “Grass” in the 1st dropdown. I am either able to show all 4 options in the 2nd dropdown or none at all.
Could you please help me setting up the “Choices Source” for 2nd dropdown?

Thanks in advance