Dropdown Variables

I would like to have a dropdown that shows the categories then based on which category is selected the second drop down will only show products from that category.
Example: The Categories are fruits and vegetables
If you click fruit in the dropdown, then you only see fruit, no vegetables.

I just ended up making the categories themselves, products and then having each of the products as options.