This repository was archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodolist2.html
More file actions
61 lines (52 loc) · 1.91 KB
/
todolist2.html
File metadata and controls
61 lines (52 loc) · 1.91 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
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<title>TO DO LIST 2</title>
</head>
<body>
<form id="form">
TASK :<br>
<input type="text" name="task" id="task" >
<input id="add" type="button" name="add" value="ADD" onclick="add1()">
<p id="para"></p>
</form>
</body>
<script>
var val;
var str;
var n=0; //id no.s
var arr=[]; //stores the task value
var c=[];// stores the status of the checkboxes-> even means unchecked ,odd means checked
function add1()
{ console.log("added");
var tex=document.createElement('span');
var nl=document.createElement('br');
tex.innerHTML= document.getElementById("task").value;
var chec=document.createElement('input');
chec.id=n;
chec.type="checkbox";
chec.value=document.getElementById("task").value;
chec.onclick=function()
{
//console.log("check strike")
if(this.checked==true)
{
this.nextElementSibling.style.setProperty("text-decoration", "line-through")
//console.log("content striked")
}
else
{
this.nextElementSibling.style.textDecoration='none'
//console.log("content unstriked")
}
}
n+=1;
console.log("added2");
document.getElementById("task").value="";
console.log(chec.value);
document.getElementById("para").appendChild(chec);
document.getElementById("para").appendChild(tex);
document.getElementById("para").appendChild(nl);
}
</script>
</html>