-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToDoUpdate1.html
110 lines (78 loc) · 2.35 KB
/
ToDoUpdate1.html
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<html>
<head>
<style>
#space {
width: 250%;
text-align: left;
color: black;
padding: 4%;
}
#space1 {
padding: 7px;
}
div.bottom {
position: absolute;
bottom: 10px;
}
.dark {
width: 700px;
height: 100px;
background-repeat: no-repeat;
background-size: 300px 100px;
background-color: aqua;
text-decoration-line: line-through;
}
</style>
<script type="text/javascript">
function process()
{
xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange= function(){
if(xmlHttp.readyState==4 && xmlHttp.status==200 )
{
Text = JSON.parse(xmlHttp.responseText);
document.getElementById("new1").innerHTML=Text.name;
// var value = document.createElement("P");
// value.innerHTML =Text.name;
document.getElementById("mydiv").innerHTML="";
}
}
xmlHttp.open("GET","https://5e2ac93c4fdc030014e20c2a.mockapi.io/api/v1/get/3",true);
xmlHttp.send();
// xmlHttp.open("POST","https://5e2ac93c4fdc030014e20c2a.mockapi.io/api/v1/get",true);
// xmlHttp.send(x);
}
var i=1;
function change() {
var x = document.createElement("P");
x.innerHTML = document.getElementById("space").value;
x.onclick = () => { myFunction(x) };
var items = document.getElementById('text');
items.appendChild(x);
document.getElementsByTagName("P")[i].setAttribute("type",i);
i=i+1;
document.getElementById("space").value = "";
}
function myFunction(element) {
var imp= element.getAttribute("type");
document.getElementById("new").innerHTML=imp;
element.classList.toggle("dark");
xmlHttp.open("Delete","https://5e2ac93c4fdc030014e20c2a.mockapi.io/api/v1/get/"+imp,true);
xmlHttp.send();
document.getElementById("mydiv").innerHTML="processing...."
}
</script>
</head>
<body onload="process()">
<div id="text">
<p id="new"> hi bay</p>
<p id="new1"> hi bay</p>
</div>
<div id="mydiv">
</div>
<div class=bottom>
<input id="space" type="text" placeholder="Enter the text...">
<button id="space1" onclick="change()">Submit</button>
</div>
</body>
</html>