forked from freak-10/to-do-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
75 lines (70 loc) · 1.99 KB
/
index.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
<html>
<head>
<title>To-Do List</title>
<script>var c=0;
function addlistitem(){
var s = document.getElementById("new").value;
if(s.length===0)
return false;
var td1 = document.createElement("td");
var tr = document.createElement("tr");
var table = document.getElementById("table");
table.appendChild(tr);
td1.innerHTML=s;
tr.appendChild(td1);
td1.bgColor="tomato";
document.getElementById("new").value = "";
var td2 = document.createElement("td");
var dlt = document.createElement("button");
dlt.innerHTML="X";
td2.appendChild(dlt);
tr.appendChild(td2);
dlt.onclick=deletelistitem;
td1.onclick=changecolor;
c++;
tr.id=c;
td1.width="90%";
function changecolor(){
if(td1.bgColor=="tomato")
td1.bgColor="lime";
else
td1.bgColor="tomato";
}
function deletelistitem(){
if(confirm("Confirm deletion?")===false)
return false;
var index = parseInt(tr.id);
table.removeChild(table.childNodes[index]);
var i;
for(i=index+1;i<=c;i++)
{
document.getElementById(i).id=i-1;
}
c--;
}
}
</script>
</head>
<body>
<font face="courier">
<center><h1><b><u>To-Do List</u></b></h1></center>
<hr>
<label>New Item:</label>
<input type ="text" size="50" placeholder="Enter new to-do here..." id="new"> <button id="add" onClick="addlistitem()">+</button>
<br><br>
<font color="red"><b>Red means incomplete</b></font>
<br>
<font color="green"><b>Green means complete</b></font>
<br>
Click on the respective item to change status
<br>
Click on 'X' to remove item
<br>
<hr>
<center><table width="80%" cellpadding="10" id="table">
</table></center>
</font>
<hr>
<p> Beta version </p>
</body>
</html>