-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessing.js
77 lines (62 loc) · 2.12 KB
/
processing.js
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
72
73
74
75
76
var xhr = false;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
var itemNumber;
function displayProcessingTable()
{
//alert("Processing Table Display!");
xhr.open("GET", "getGoodsTable.php?id="+Number(new Date), true);
xhr.send();
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && xhr.status == 200)
{
var i;
var xmlDoc = xhr.responseXML;
var table1 = "<tr><th> Item Number </th><th> Item Name </th> <th> Price </th> <th> Quantity Available </th> <th> Quantity on Hold </th> <th> Quantity Sold </th></tr>";
var x = xmlDoc.getElementsByTagName("item");
for (i = 0; i <x.length; i++)
{
itemNumber = x[i].getElementsByTagName("itemnumber")[0].childNodes[0].nodeValue;
//itemNumber = "cool";
table1 += "<tr><td>" +
itemNumber +
"</td>" +
"<td>" +
x[i].getElementsByTagName("itemname")[0].childNodes[0].nodeValue +
"</td>" +
"<td>" +
x[i].getElementsByTagName("itemprice")[0].childNodes[0].nodeValue.substring(0, 20) + //Displaying only first 20 chracters of description
"</td>" +
"<td>" +
x[i].getElementsByTagName("itemquantity")[0].childNodes[0].nodeValue +
"</td>" +
"<td>" +
x[i].getElementsByTagName("quantityonhold")[0].childNodes[0].nodeValue +
"</td>" +
//"<td>" + "<a href=\"#\" onclick=\"addRemoveItem(\"Remove\","+itemNumber+")\"> Add one to the cart </a>" + "</td>"
"<td>" +
x[i].getElementsByTagName("quantitysold")[0].childNodes[0].nodeValue
+ "</td></tr>";
}
document.getElementById("processingTable").innerHTML = table1;
}
}
}
function processXML()
{
xhr1 = new XMLHttpRequest();
//alert("PROCESS BUTTON CLICKED!");
xhr1.open("GET", "processing.php?id="+Number(new Date), true);
xhr1.send();
xhr1.onreadystatechange = function()
{
//alert(xhr1.responseText);
}
displayProcessingTable();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////