-
Notifications
You must be signed in to change notification settings - Fork 3
/
anna.js
65 lines (64 loc) · 2.82 KB
/
anna.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
var btn = document.getElementById("add_new");
var btn2 = document.getElementById("add_new2");
var addNewGame = document.getElementById("addNewGame")
var addNewGame2 = document.getElementById("addNewGame2")
function addGame(formInputId){
var opponentName = document.createElement("input")
opponentName.setAttribute("type", "text")
opponentName.setAttribute("name", "opponent")
opponentName.setAttribute("placeholder", "opponent name")
var userScore = document.createElement("input")
userScore.setAttribute("type", "number")
userScore.setAttribute("name", "userScore")
userScore.setAttribute("placeholder", "your score")
var opponentScore = document.createElement("input")
opponentScore.setAttribute("type", "number")
opponentScore.setAttribute("name", "opponentScore")
opponentScore.setAttribute("placeholder", "their score")
var submit = document.createElement("input")
submit.setAttribute("type", "submit")
formInputId.appendChild(opponentName)
formInputId.appendChild(userScore)
formInputId.appendChild(opponentScore)
formInputId.appendChild(submit)
}
btn.addEventListener("click", function(){
var opponentName = document.createElement("input")
opponentName.setAttribute("type", "text")
opponentName.setAttribute("name", "opponent")
opponentName.setAttribute("placeholder", "opponent name")
var userScore = document.createElement("input")
userScore.setAttribute("type", "number")
userScore.setAttribute("name", "userScore")
userScore.setAttribute("placeholder", "your score")
var opponentScore = document.createElement("input")
opponentScore.setAttribute("type", "number")
opponentScore.setAttribute("name", "opponentScore")
opponentScore.setAttribute("placeholder", "their score")
var submit = document.createElement("input")
submit.setAttribute("type", "submit")
addNewGame.appendChild(opponentName)
addNewGame.appendChild(userScore)
addNewGame.appendChild(opponentScore)
addNewGame.appendChild(submit)
})
btn2.addEventListener("click", function(){
var opponentName = document.createElement("input")
opponentName.setAttribute("type", "text")
opponentName.setAttribute("name", "opponent")
opponentName.setAttribute("placeholder", "opponent name")
var userScore = document.createElement("input")
userScore.setAttribute("type", "number")
userScore.setAttribute("name", "userScore")
userScore.setAttribute("placeholder", "your score")
var opponentScore = document.createElement("input")
opponentScore.setAttribute("type", "number")
opponentScore.setAttribute("name", "opponentScore")
opponentScore.setAttribute("placeholder", "their score")
var submit = document.createElement("input")
submit.setAttribute("type", "submit")
addNewGame2.appendChild(opponentName)
addNewGame2.appendChild(userScore)
addNewGame2.appendChild(opponentScore)
addNewGame2.appendChild(submit)
})