Skip to main content

Interactive Booking Examples

DHTMLX Booking is a client-side JavaScript component for showing available time slots and taking reservations. It gives you a searchable card list, working hours per card, and a booking dialog you can shape and validate. Explore the interactive demos below to see its features in action, or visit the official documentation for the full API reference.

const widget = new booking.Booking("#root", {
	start: buildToday(),
    data: dataset,
});

widget.setConfirmHandler(function(event){
    const { confirm } = event;
    setTimeout(() => {
        Math.random() < 0.5 ? confirm.error() : confirm.done();
    }, 1000);
});
<!-- component container -->
<div id="root" style="height:100%"></div>

<!-- dataset -->

<script>
function buildToday(){const params = new URLSearchParams(typeof location !== 'undefined' ? location.search : '');const fixed = params.get('fixedDate') || (typeof window !== 'undefined' && window.FIXED_DATE);return fixed ? new Date(fixed) : new Date();}

	const dataset = [
      {
        id: "ee828b5d-a034-420c-889b-978840015d6a",
        title: "Natalie Tyson",
        category: "Therapist",
        subtitle: "2 years of experience",
        details: "Cleveland Clinic\n9500 Euclid Ave",
        preview: "https://snippet.dhtmlx.com/codebase/data/booking/01/img/01.jpg",
        price: "$35",
        review: {
            stars: 4,
            count: 120,
        },
        slots: [
            {
                from: 9,
                to: 20,
                days: [1, 2, 3, 4, 5],
            },
            {
                from: 10,
                to: 18,
                days: [6, 0],
            },
        ],
    },
      {
        id: "5c9b64ad-1830-4e5b-a5f9-8acea10706df",
        title: "James Anderson",
        category: "Allergist",
        subtitle: "3 years of experience",
        details: "UCLA Medical Center\n57 Westwood Plaza",
        preview: "https://snippet.dhtmlx.com/codebase/data/booking/01/img/11.jpg",
        price: "$30",
        review: {
            stars: 4,
            count: 64,
        },
        slotSize: 45,
        slotGap: 10,
        slots: [
            {
                from: "9:15",
                to: 17,
                days: [1, 2, 3, 4, 5],
            },
        ],
    },
      // ... 44 more items (see Live Editor for full data)
    ];

function getDate(addDays, hoursValue = 0, minutesValue = 0) {
	const date = buildToday();
	const secondsValue = 0; // round to minutes
	const msValue = 0;

	date.setDate(date.getDate() + addDays);
	date.setHours(hoursValue, minutesValue, secondsValue, msValue);

	return date.getTime();
}
</script>

Getting started​

Set up the widget and the schedule:

Cards and dialog​

Decide what the visitor sees before and during a booking, and how it looks:

Data and performance​

Feed the widget from a real system:

Framework and widget integration​

Run the widget inside a framework or pair the visitor view with a planning tool:

Additional resources​