-
Notifications
You must be signed in to change notification settings - Fork 0
/
lahacienda.js
145 lines (126 loc) · 3.83 KB
/
lahacienda.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
function increaseValue() {
var value = parseInt(document.getElementById('number').value, 10);
value = isNaN(value) ? 1 : value;
if (value >= 10) {
value = 10;
}
else {
value++;
}
document.getElementById('number').value = value;
}
function decreaseValue() {
var value = parseInt(document.getElementById('number').value, 10);
value = isNaN(value) ? 1 : value;
if (value <= 1) {
value = 1;
}
else {
value--;
}
document.getElementById('number').value = value;
}
function successMsg() {
alert("Message sent succesfully!");
}
function successReg() {
alert("Registration succesful!");
}
function successReset() {
alert("Password reset link sent!");
}
function successProd() {
alert("Product edited succesfully!");
}
function successProfile() {
alert("Customer profile edited succesfully!");
}
function forApproval() {
alert("Order submitted for approval!");
}
function showPassword() {
var x = document.getElementById("psw");
var y = document.getElementById("psw-repeat");
if (x.type === "password") {
x.type = "text";
y.type = "text";
} else {
x.type = "password";
y.type = "password";
}
}
function addToCart() {
alert("Item added to cart!");
}
function updatePrices2() {
var table = document.getElementById("cart");
var price, qt;
for (var i = 0, cell; cell = table.cells[i]; i++) {
if(cell.id = "pricedata") {
price = document.getElementById("pricedata").value;
}
if(cell.id = "qtdata") {
qt = document.getElementById("qtdata").value;
}
if(cell.id= "subtotaldata") {
document.getElementById("subtotaldata").innerHTML = '<span style="float:right;">$price*qt</span>';
}
}
}
function updatePrices() {
if (document.body.contains(document.getElementById('quantity1'))) {
var q1 = document.getElementById('quantity1').value;
}
else {
var q1 = 0;
}
if (document.body.contains(document.getElementById('quantity2'))) {
var q2 = document.getElementById("quantity2").value;
}
else {
var q2 = 0;
}
var p1 = document.getElementById("price1").value;
var p2 = document.getElementById("price1").value;
var subtotal1 = q1*p1;
var subtotal2 = q2*p2;
var subtotal = subtotal1 + subtotal2;
var gst = Number((subtotal * 0.05).toFixed(2));
var pst = Number((subtotal * 0.09975).toFixed(2));
var grandtotal = Number((subtotal + gst + pst).toFixed(2));
if (document.body.contains(document.getElementById('subtotal1'))) {
document.getElementById("subtotal1").innerHTML = "$" + subtotal1;
}
if (document.body.contains(document.getElementById('subtotal2'))) {
document.getElementById("subtotal2").innerHTML = "$" + subtotal2;
}
document.getElementById("subtotal").innerHTML = "$" + subtotal;
document.getElementById("gst").innerHTML = "$" + gst;
document.getElementById("pst").innerHTML = "$" + pst;
document.getElementById("grandtotal").innerHTML = "$" + grandtotal;
}
function checkPW() {
if (document.getElementById('psw').value ==
document.getElementById('psw-repeat').value) {
document.getElementById('message').style.color = 'green';
document.getElementById('message').innerHTML = 'Passwords match';
} else {
document.getElementById('message').style.color = 'red';
document.getElementById('message').innerHTML = 'Passwords do not match';
}
}
/*
function updater() {
var table = document.getElementById("cart");
var subtotal1, subtotal2;
for (var i = 0, row; row = table.rows[i]; i++) {
for (var j = 2, col; col = row.cells[j]; j++) {
row.cells[j].
}
}
}
*/
function removeRow(x) {
var p = x.parentNode.parentNode;
p.parentNode.removeChild(p);
}