-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddPlayer.js
More file actions
50 lines (43 loc) · 1.31 KB
/
addPlayer.js
File metadata and controls
50 lines (43 loc) · 1.31 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
let localTeam = JSON.parse(localStorage.getItem("teamArray"));
let localPlayers = JSON.parse(localStorage.getItem("playerArray"));
var selectTeam=document.getElementById("inp6")
for(var i=0;i<localTeam.length;i++){
selectTeam.innerHTML+=`
<option value="${localTeam[i].teamFullName}">${localTeam[i].teamFullName}</option>
`
}
var newData=10
$("#addteamform").submit(function (e) {
e.preventDefault();
let inp_val = $("#inp6").val();
let shortName = '';
for(let i=0;i<inp_val.length;i++){
if(i == 0){
shortName += inp_val[i++].toUpperCase();
continue;
}else if(inp_val[i] == ' '){
shortName += inp_val[++i].toUpperCase();
i++;
}
}
var trueOrFal=""
if($("#inp3").val()=="true"){
trueOrFal=true
}
else{
trueOrFal=false
}
let addPlayer={
"id":localPlayers.length,
"playerName": $("#inp1").val(),
"from": shortName,
"price": $("#inp2").val()+"Cr",
"isPlaying": trueOrFal,
"description": $("#inp4").val(),
"playerImg": $("#inp5").val(),
"playerTeam": $("#inp6").val(),
}
localPlayers.push(addPlayer)
localStorage.setItem('playerArray',JSON.stringify(localPlayers))
location.href = "index.html";
})