/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1

« back to all changes in this revision

Viewing changes to trunk/Code Viewer Alt/AJAX/AjaxDemoApp2_getCustomerBookings.html

  • Committer: Henrik G.
  • Date: 2013-03-26 23:22:55 UTC
  • Revision ID: henrik.gustavsson@his.se-20130326232255-ik6snyatlbkf3zs1
First seed of Lenasys ... Needs to be Organized Further

Show diffs side-by-side

added added

removed removed

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