I have a logic challenge

I have a form that populates an email message using the $_POST.variable. What I want to do is the following:

  1. Select a time for a meeting from a dropdown.
    The meeting timeframe is choice of 8:00 AM, 9:00 AM, 1:30 PM, 2:00 PM.
  2. Click a date picker and select a date for the meeting.
  3. The next date will be for the hotel reservation. If the chosen timeframe is 8:00 AM or 9:00 AM, the
    date for the reservation should be one day earlier than the date of the meeting. If the chosen
    timeframe is later, i.e., 1:30 PM or 2:00 PM, the reservation should be the same date as meeting.

Any suggestions or help will be very appreciated.

On phone so excuse grammar.

Don’t know if best way, but you could have two reservation date fields. On one use show with an expression like:

Meeting.value <= 9

And similar for other.

I can’t offer a suggestion for your issue, but I can tell you that your layout and design is awesome! Very clean looking. I love your combination of colors, styling and icon use.

Thank you very much!

I believe I will just stick with the two date fields. Let the secretary make the determination… at least until I can find the ‘ah-ha’ moment.

If the reservation date is a fixed date depending on the meeting date/time, why do you have a picker for it? Why not generate the reservation date using an expression like {{MeetingDate.value.addDays(MeetingTime.value <= 9 ? -1 : 0)}} and show that to the user.

1 Like

The current reason is that this form is live and I didn’t want any downtime for the users. Meanwhile I am testing other means of achieving my final objective of allowing code logic manage the date.

Excellent example. My vision was blurred by my use of a form -> html email.

Thanks for clearing my head… obviously the coffee hasn’t help! I will give it a go and see how it works.

Thanks again!

Patrick:

Thanks for your help. I must be missing some steps or misappropriating your expression. What information would you need from me to help me understand where I am going astray?

Thank you for your guidance!

In the expression I asume that the id of the meething date picker is MeetingDate and the dropdown id is MeetingTime. I also asume that the values from the dropdown are just numbers, that would make it easier to use in the expression. So 8:00 AM would become 8, 1:30 PM would become 13.5. When it is a number you can just say MeetingTime.value <= 9 to see if the time is 9:00 AM or earlier.

So the complete expression says, take the value of MeetingDate and add -1 day when MeetingTime value <= 9. Adding -1 day will result in the day before the MeetingDate.

If you have the values as strings 8:00, 9:00 etc, then the expression gets a bit more complicated, should become something like MeetingTime.value == "8:00" || MeetingTime.value == "9:00".

1 Like

I’ll give it a go. I believe that both being strings were causing the code’s inactivity.