Overview
The bookings list is a typical function in booking systems that shows the number of bookings of a resource a certain date. This can for example be a list of rooms in a hotel that have been booked on a date.

One key flaw of the previous example is that we can only se the booked resources and that there is no way to see which resources are available. The reason for this is that we do not know the number of available resources, and therefore we do not know if there are more resources available. This example adds a function to count the available resources and a nicer display for the bookings.

processinputbox
The function called processinputbox is executed by the keyup and onchange events for the text boxes in the form. The main difference compared to the previous examples is that two functions are called, one for collecting bookings and one for retrieving the resource size.

resultBooking
The resultBookings function calls the drawResult function and updates a boolean so that the engine knows that the resource size is valid.

resultSize
The booking/getresourcesize_XML.php returns a very simple dataset with a single element containing a single attribute.

drawResult
The most important new function is the drawResult function which draws a table containing the avtilable resources. The reason for moving this into a separate function is that this function can be called outside of the scope of the AJAX engine for example if the bookings are drawn using html5 rather than using a table as in this example.

The code is mostly the same as in the previous example, except for the counter i, which is increased for each possible booking position. The counter is then used to insert table rows using modulo (division rest function) i%4==3 means that a table row is inserted every 4th booking.

getBookingsForDate
The booking/getbookings_XML.php can retrieves all bookings of a resourceID for a certain date. This was detailed in the previous example.

getResourceSize
booking/getresourcesize_XML.php Retrieves the size of a resource with a given resourceID.

Call Example:

$.ajax({
	type: 'POST',
	url: 'booking/getresourcesize_XML.php',
	data: {	resourceID: resource},
	success:  ResultSize
});												


Returned Data Example:

<resources>
<resource 
    size='24'
 />
</resources>