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.
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.
@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.
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.