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
66
67
68
69
70
71
|
<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 resource name, company or location and/or a fulltext
function showResources(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. resources)
for (i = 0; i < resultset.childNodes.length; i++) {
// Iterate over all child nodes of that node that are resource nodes
if(resultset.childNodes.item(i).nodeName=="resource"){
// Retrieve data from resource nodes
var resource=resultset.childNodes.item(i);
output+="<tr onclick='alert(\""+resource.attributes['id'].value+"\")'>";
output+="<td>"+resource.attributes['company'].nodeValue+"</td>";
output+="<td>"+resource.attributes['name'].nodeValue+"</td>";
output+="<td>"+resource.attributes['location'].nodeValue+"</td>";
output+="</tr>";
}
}
output+="</table>"
var div=document.getElementById('OutputDiv');
div.innerHTML=output;
}
function searchResources()
{
var resname=document.getElementById("resName").value;
var reslocation=document.getElementById("resLocation").value;
var rescompany=document.getElementById("resCompany").value;
var resfulltext=document.getElementById("resFulltext").value;
$.ajax({
type: 'POST',
url: '../booking/getresources_XML.php',
data: { name: escape(document.getElementById("resName").value),
location: escape(document.getElementById("resLocation").value),
company: escape(document.getElementById("resCompany").value),
fulltext: escape(document.getElementById("resFulltext").value) },
success: showResources
});
}
</script>
</head>
<body>
<form name='searchbookings'>
Name:</br>
<input type='text' value='' name='resName' id='resName' onchange="searchResources()" onkeyup="searchResources()"></br>
Location:</br>
<input type='text' value='' name='resLocation' id='resLocation' onchange="searchResources()" onkeyup="searchResources()"></br>
Company:</br>
<input type='text' value='' name='resCompany' id='resCompany' onchange="searchResources()" onkeyup="searchResources()"></br>
Freetext:</br>
<input type='text' value='' name='resFulltext' id='resFulltext' onchange="searchResources()" onkeyup="searchResources()"></br>
</form>
<br>
<div id="OutputDiv">
<br>
</body>
</html>
|