-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloadListing.js
114 lines (103 loc) · 2.44 KB
/
loadListing.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//Create xHRObject for ajax request and response
var xHRObject1 = false;
if(window.XMLHttpRequest)
xHRObject1 = new XMLHttpRequest();
else if(window.ActiveXObject)
xHRObject1 = new ActiveXObject("Microsoft.XMLHTTP");
//Function to load the categories in listing page
function fnLoadListing()
{
xHRObject1.open("GET", "LoadItems.php?id=" + Number(new Date), false);
xHRObject1.onreadystatechange = function()
{
if (xHRObject1.readyState == 4 && xHRObject1.status == 200)
{
Categories = xHRObject1.responseText;
//Split the string
var arrCategories = Categories.split("^");
var x=document.getElementById("drpCategory");
var option=document.createElement("option");
option.text="Others";
// for IE earlier than version 8
//x.add(option,x.options[null]);
var length = arrCategories.length;
if(length <= 1)
document.getElementById("txtbox").style.display="inline";
var Category = "";
for (var i = 1; i < length-1; i++)
{
Category = arrCategories[i];
x.options[x.length] = new Option(Category, Category);
}
x.options[x.length] = new Option('Others', 'Others');
LoadDuration();
}
}
xHRObject1.send(null);
}
function LoadDuration()
{
LoadDays();
LoadHours();
LoadMinutes();
}
function LoadDays()
{
var x=document.getElementById("drpDays");
var option=document.createElement("option");
for(var i=0 ; i<32 ;i++)
{
option.text=i;
try
{
// for IE earlier than version 8
//x.add(option,x.options[null]);
x.options[x.length] = new Option(i, i);
}
catch (e)
{
//x.add(option,null);
x.options[x.length] = new Option(i, i);
}
}
}
function LoadHours()
{
var x=document.getElementById("drpHours");
var option=document.createElement("option");
for(var i=0 ; i<24 ;i++)
{
option.text=i;
try
{
// for IE earlier than version 8
//x.add(option,x.options[null]);
x.options[x.length] = new Option(i, i);
}
catch (e)
{
//x.add(option,null);
x.options[x.length] = new Option(i, i);
}
}
}
function LoadMinutes()
{
var x=document.getElementById("drpMinutes");
var option=document.createElement("option");
for(var i=0 ; i<60 ;i++)
{
option.text=i;
try
{
// for IE earlier than version 8
//x.add(option,x.options[null]);
x.options[x.length] = new Option(i, i);
}
catch (e)
{
//x.add(option,null);
x.options[x.length] = new Option(i, i);
}
}
}