Using your own Date inputs
This section will show you how to use an HTML form to capture dates from the user, then submit those dates when opening the Booking Engine Widget.
Important: Make sure you fulfill all the required Prerequisites. Without doing so, the code of the use cases can be hard to understand or the behavior of the code can differ from what you expect.
Sample code
Below is some sample HTML and Javascript code to demonstrate the functionality. Numbered notes beneath the code snippet relate to the numbered comments within the code.
1. Install booking engine loader script
For more details, see Install booking engine loader script.
2. Add form with date inputs
We've added just a simple form with date inputs as an example to give you an idea of how to connect your own HTML elements. On your own page you can use any date inputs you want, you just need to connect them with the Booking Engine Widget. The submit button in the form is disabled at page load, so users can't submit the form before the form and the Booking Engine Widget are ready to be used. We enable it later when they're ready.
3. Initialize Booking Engine Widget
For more details, see Initialize Booking Engine Widget. If you are not sure where to find the Configuration ID, see the FAQ.
4. This guide is written for the Production environment
If you want to test this code in a different environment, please refer to our guide for Testing in the Demo environment.
Conclusion
In this guide, you've learned how to add a simple form with date inputs to your page and connect its submit button to the Booking Engine Widget. So when users select their dates and submit the form, the Booking Engine Widget will open with those dates already selected. The Booking Engine Widget Javascript API supports more than just setting dates - see the full Javascript API Reference to find other options you could use.
Last updated