1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<html>
<head>
<style>
table {border: 1px dotted gray; padding: 1em;}
</style>
<script language="javascript" src="../jquery/jquery-1.8.2.min.js"></script>
<script language="javascript">
// The API is passed a customer ID and the name of the return function
function ResultBookingCustomer(returnedData)
{
// An XML DOM document is returned from AJAX
var resultset=returnedData.childNodes[0];
var output="<table>";
// Iterate over all nodes in root node (i.e. bookings)
for (i = 0; i < resultset.childNodes.length; i++) {
// Iterate over all child nodes of that node that are booking nodes
if(resultset.childNodes.item(i).nodeName=="booking"){
// Retrieve first name and last name for node
var booking=resultset.childNodes.item(i);
output+="<tr>";
output+="<td>"+booking.attributes['company'].nodeValue+"</td>";
output+="<td>"+booking.attributes['name'].nodeValue+"</td>";
output+="<td>"+booking.attributes['location'].nodeValue+"</td>";
output+="<td>"+booking.attributes['date'].nodeValue+"</td>";
output+="</tr>";
}
}
output+="</table>"
var div=document.getElementById('OutputDiv');
div.innerHTML=output;
}
function processinputbox()
{
customer =document.getElementById("customerID").value;
$.ajax({
type: 'POST',
url: '../booking/getcustomerbookings_XML.php',
data: {
customerID: escape(customer)
// type: 'Hotell_Demo' // Optional: Can be specified to filter out bookings made from a certain application.
},
success: ResultBookingCustomer,
});
}
</script>
</head>
<body>
<form name='searchbookings'>
customerID</br>
<input type='text' name='customerID' id='customerID' onchange="processinputbox()" onkeyup="processinputbox()">
</form>
Result<br>
<div id="OutputDiv" />
</body>
</html>
|