-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
150 lines (126 loc) · 4.51 KB
/
index.html
File metadata and controls
150 lines (126 loc) · 4.51 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Task management</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body{
background-color: seagreen;
}
h2{
text-align: center;
margin-top: 25px;
}
.container{
margin-bottom: 55px;
}
.input{
border: 2px solid white;
border-radius: 5px;
width: 45%;
margin-top: 4px;
}
#add{
margin-top: 18px;
}
.footer{
position: fixed;
padding: 10px 10px 0px 10px;
bottom: 0;
width: 100%;
height: 40px;
background: rgb(8, 100, 48);
text-align: center;
color: white;
}
</style>
</head>
<body>
<h2>Task Management</h2><br><br>
<div class="container">
<div class="row">
<div class="col-md-3">
<form action="">
Add new Task: <br> <input type="text" placeholder="Enter Task" name="input" id="input" class="input" maxlength="30">
</form>
</div>
<div class="col-md-3">
Select Priority <br>
<select name="" id="priority" class="input">
<option value="Low">Low</option>
<option value="Medium">Medium</option>
<option value="High">High</option>
</select>
</div>
<div>
<button class="btn btn-primary" id="add" onclick="addTask()">Add task</button>
</div>
</div>
<br>
<h3 id="text">Tasks: <span id="message" style="font-weight: 100; font-size: smaller;"></span></h3>
<table id="table" class="table">
<tr>
<th>Task</th>
<th>Priority</th>
<th>Status</th>
<th>Actions</th>
</tr>
<tbody id="tasks">
</tbody>
</table>
</div>
<div class="footer">
©<a href="https://github.com/vansh-codes/" style="color: white;"> vansh-codes</a> 2024
</div>
<script>
function addTask(){
let input = document.getElementById("input");
let taskName = input.value;
let priority = document.getElementById("priority").value;
let status = 'pending';
if(taskName.trim() == ''){
alert("Please enter a task");
return;
}
let tasks = document.getElementById("tasks");
const newRow = tasks.insertRow();
newRow.innerHTML =
`
<td>${taskName}</td>
<td>${priority}</td>
<td>${status}</td>
<td>
<button class="btn btn-success" onclick="completeTask(this)">Complete</button>
<button class="btn btn-danger" onclick="deleteTask(this)">Delete</button>
</td>
`;
document.getElementById("message").textContent = "Task added successfully";
setTimeout(function(){
document.getElementById("message").textContent = "";
},1000);
input.value = '';
}
function completeTask(button){
const row = button.closest('tr');
if(row.cells[2].textContent == 'Completed'){
alert("Task already completed");
}
row.cells[2].textContent = 'Completed';
document.getElementById("message").textContent = "Task completed successfully";
setTimeout(function(){
document.getElementById("message").textContent = "";
},1000);
}
function deleteTask(button){
const row = button.closest('tr');
row.remove();
document.getElementById("message").textContent = "Task deleted successfully";
setTimeout(function(){
document.getElementById("message").textContent = "";
},1000);
}
</script>
</body>
</html>