-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (41 loc) · 1.7 KB
/
index.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
var data = document.getElementById('data');
var userList = document.getElementById('userList');
var counter=0;
function addUser()
{
var inputData= document.getElementById("data").value;
var print = '<div class="row" id="data'+counter+'">'+
'<div class="col-md-6">'+
'<input type="text" style="width:240px;" class="form-control" value="'+inputData+'" disabled > <br> '+
'</div>'+
'<div class="col-md-2">'+
'<button type="button" class="btn btn-warning" onclick="change(this.id)" id="change'+counter+'" style="width: 130px;" > Edit</button>'+
'</div>'+
'<div class="col-md-2">'+
'<button type="button" class="btn btn-primary" onClick="update(this.id)" id="update'+counter+'" style="width: 130px;" id="update'+counter+'"> Update</button>'+
'</div>'+
'<div class="col-md-2">'+
'<button type="button" class="btn btn-danger" style="width: 130px;" onClick="remove(this.id)" id="remove'+counter+'"> Delete</button>'+
'</div>'+
'</div>'
document.getElementById('userList').insertAdjacentHTML('beforeend',print);
counter++;
}
function change(changeId){
var parent = document.getElementById(changeId).parentNode.parentNode;
var child= parent.firstChild.firstChild;
child.removeAttribute('disabled');
console.log(child);
}
function update(updateId)
{
var parent = document.getElementById(updateId).parentNode.parentNode;
var child= parent.firstChild.firstChild;
child.setAttribute('disabled','disabled');
console.log(child);
}
function remove(removeId)
{
var parent = document.getElementById(removeId).parentNode.parentNode;
parent.remove() ;
}