Forum Academy Marketplace Showcase Pricing Features

Using Time Range in Dropdowns

I have two Dropdowns in my app that contain dynamic choices from my app data of times in a 24 hours period by 15 minute intervals.

00:00
00:15
00:30
00:45
01:00
01:15
01:30
…and so on.

This allows the user to choose between times, for example, between 14:30 and 15:30

How do I set up a condition, such as “if Dropdown2’s value < Dropdown1’s value = show error message”. This is to prevent the user selecting incompatible times, such as something like “between 14:30 and 13:30 hours”.

I’ve created a new field (number) referencing each time, for example
1 12:00
2 12:15
3 12:30
4 12:45
5 13:00
…and so on.

But I am struggling to find a formula or expression that prevents a lesser number being selected. If that makes sense.

I am hoping I can set up a condition that will display a Text Element telling the user that there is an error with the time range.

Hope someone can help.

Thank you,

Mike.

In your app data, you could have a sorting field. So that 00:00 sorts to 0, 00:15sorts to 1 and so on.
Then, in the “to” dropdown, have a constraint that says this dropdown’s sorting > “from” dropdown’s sorting.

1 Like

Would you mind sharing your full setup with the time slots and how they are used?

1 Like

Thank you @pnodseth I very much like that.

@jonaspalmqvist It’s just two dropdowns that allows the user to choose between times, for example, “13:00 to 14:00 hours”. The times are stored in my app data, along with a sorting field. And as @pnodseth has shown me, when the user selects, for example 01:00 in the first dropdown, the second dropdown will automatically choose a time ahead - making it clear to the user what is required.

Just to add, in case anyone having a similar problem in the future…

I have also managed to use the same method to display a text element whenever the user still manages to pick a “wrong time”.

You know you can add alert messages instead of texts? visual elements > alerts. Check it out. They are better designed for what you are doing there. You can also customise them to fit your needs ofc.

2 Likes

Thanks @jonaspalmqvist

I haven’t played around with the alerts yet. When I start finalising my app, I will defo look at having them instead.

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