-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (28 loc) · 1.04 KB
/
Copy pathscript.js
File metadata and controls
35 lines (28 loc) · 1.04 KB
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
let addBtn = document.getElementById("addBtn");
let formBox = document.getElementById("formBox");
let saveBtn = document.getElementById("saveMatch");
let matchArea = document.getElementById("matches");
addBtn.onclick = function () {
if (formBox.style.display === "none") {
formBox.style.display = "block";
} else {
formBox.style.display = "none";
}
};
saveBtn.onclick = function () {
let playerOne = document.getElementById("p1").value;
let playerTwo = document.getElementById("p2").value;
let scoreVal = document.getElementById("scoreInput").value;
if (playerOne === "" || playerTwo === "" || scoreVal === "") {
alert("Please fill everything");
return;
}
let div = document.createElement("div");
div.className = "matchItem";
div.innerHTML = "<b>" + playerOne + "</b> vs <b>" + playerTwo + "</b> - " + scoreVal;
matchArea.appendChild(div);
document.getElementById("p1").value = "";
document.getElementById("p2").value = "";
document.getElementById("scoreInput").value = "";
formBox.style.display = "none";
};