Skip Navigation

[Resolved] do processing before submit form and after date selected

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#922125

Dear
I have a form where user can select a starting date and ending date for his booking and when clicking on submit button, the system will book a room for him on those dates. Now, what i want to do is before user clicks on submit button (but after he selects the end date), the form should show him the total he will have to pay (this should be calculated based on these 2 dates and other criteria as well such as the type of room selected and the type of logged user). How can I achieve this please? I have a php code in functions.php which is already calculating the amount, but how I can call it before I click on submit button?

Regards
Nabil

#922297

Dear Nabil,

There isn't such a built-in feature within Views plugin, it requires custom codes.

after user has changed the ending date field value, you can setup some custom JS codes to do the calculation, for example:
hidden link

If you need to calculate in the server side with PHP codes, you can try to trigger AJAX request:
hidden link

In server side, register an action to do the calculation and answer the AJAX request, see wordpress document:
https://codex.wordpress.org/AJAX_in_Plugins