How to attribute values to buttons that change: custom state or smth else?

hello, everyone and thanks very much for all your help.

I am practicing by creating a searching tool that searches for the content of a specific component in foods. a search function i want to implement are 3 buttons, low medium and high that when clicked would filter the amount of that component the food has. low is from 0 to 36 medium to 37 to 51 and high from 52 to 100. I want to understand what would be the right tool to create this. I believe it would be a custom state but not entirely sure how would that work and how would the constraints need to be applied on the repeating group. How can I attribute a value to be a range from x to y. Alternatively the other side of my brain says this should be a database element.

which one do you reccomend i should follow with?

photo:

Thanks again for your help,

1 Like

In my apps I create an Option set.

So the option set would have 3 options (low, medium and high). I would add an attribute to the option set called low which is of type number and another attribute called high which is also of type number.

Then on the page I would use a repeating group with the datasource being the Option set all options. Then in the repeating group I would put the buttons.

The button text would be current cells options display (ie: low, medium or high).

Then when I want to use the selection of the user in another area, such as to filter a repeating group list of things via constraints, I would need to store the selected value somehow, which can be a custom state or URL parameter or even a group datasource. Seems like you are familiar with custom states, so you could use that approach. The custom state type would be the option set.

Then when a user clicks a button set the custom state to ‘current cells option’.

Now you have the selected value saved as custom state and can use it in other areas.

For a search constraint you would reference the custom state value and if needing to constrain by the high would reference the attribute high, or low if needing to constrain by low value.

1 Like

As someone who is fairly new, I’m not familiar with Option sets yet, would you use a similar method to convert a dropdown menu selection (short, med, long) to a number that is used in an API key value?

I could yes…just need to match the value from the API call to the correct option.