-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexcel.js
81 lines (56 loc) · 1.7 KB
/
excel.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
// Total sales: F = E * C
//Total Profit: G = E * D
console.log("Run");
var unitCol = document.querySelector("#units");
console.log(unitCol);
unitCol.style.backgroundColor = "red";
unitCol.style.border = "2px solid black";
unitCol.textContent = "0";
unitCol.addEventListener("input", handleClick);
function handleClick(e) {
// G = E * D (Columns)
// E:
let unitsProjected = e.target;
// G:
let G = unitsProjected.nextElementSibling.nextElementSibling;
// D:
let D = unitsProjected.previousElementSibling;
let valE = unitsProjected.textContent;
let valD = D.textContent;
valE = parseFloat(valE);
valD = parseInt(valD);
console.log(typeof valE, typeof valD);
console.log("G = ", (valE * valD));
G.textContent = valE * valD;
console.log("valE: ", valE, typeof valE);
console.log("valE: ", valD, typeof valD);
console.log(Number.isNaN(valE));
if (Number.isNaN(valE)){
G.textContent = '';
}else{
G.textContent = valE * valD;
}
}
// GIAGKAS
// let unitCol = document.querySelector("#units");
//
// unitCol.addEventListener("input",handler);
//
// //hoesting
// function handler(e){
// let profit = e.target.previousElementSibling;
// let totalProfit = e.target.nextElementSibling.nextElementSibling;
// totalProfit.textContent = parseInt(e.target.textContent) * parseInt(profit.textContent);
// }
// kati pou den petyxe
// function handler(){
// var unitCol = document.querySelector("#units");
// for (var i=0; i<Infinity; i++){
// if(i%2==0){
// unitCol.style.backgroundColor = "red";
// }else {
// unitCol.style.backgroundColor = "blue";
// }
// }
// }
// setInterval(handler, 1000);