If statement in a button

I need help in this:

There is a booking sytem in the website by scheduling an appointment selecting date and time
There will be a button in the client dashboard and the vendor dashboard. That button should be disabled all the time. It will be enabled if the date and time are met.

I am thinking of something like

If date and time are bigger than or equals to appointment data, then enable button to join a call, Else keep it disabled.

but I think the bigger than won’t work. Let’s say the appointmnet is from 10 - 11

If I choose bigger than then the button will remain enabled even if the time is 11:01 or passed 11 way forward.

What is the best practice /code to implement such statement?

Why don’t you just not display a button if the time isn’t right? It makes no sense to have a button sitting there and people clicking it “thinking” that the button will do its job. And then people complaining that the button isn’t working and saying that it’s “broken” when it really isn’t.

1 Like

Sure no problem, I can do that.

But I have the problem understanding how to create this if statement.

You first have to define the logic with a few true/false samples. I don’t really get in which situations the button would be enabled, depending on the date.

Surely you would just check for the date/time being greater than the start time and less than the end time?

I agree with @spaceshiptrooper, there are few things more annoying than displaying a button that doesn’t do anything.

3 Likes

I would suggest playing with DateTime before you take any steps. This makes sense since you want to display the button at a certain time so it is appropriate to get familiarized with the function.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.