Skip to content

complete Add function #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
<!DOCTYPE html>
<html>

<head>
<title>Todo List</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<div class="container">
<h1>Todo List</h1>
<form id="todoForm">
<form method="get" id="todoForm" onsubmit="newElemet()">
<input type="text" id="todoInput" placeholder="Enter a task">
<button type="submit">Add</button>
</form>
<ul id="todoList"></ul>
<ul id="todo_list">
<li>
<input class="checkmark" type="checkbox" name="todoItem" id="1">
<label id="item1"></label>
</li>
<li>
<input class="checkmark" type="checkbox" name="todoItem" id="2">
<label id="item2"></label>
</li>
<li>
<input class="checkmark" type="checkbox" name="todoItem" id="3">
<label id="item3"></label>
</li>
<li>
<input class="checkmark" type="checkbox" name="todoItem" id="4">
<label id="item4"></label>
</li>
<li>
<input class="checkmark" type="checkbox" name="todoItem" id="5">
<label id="item5"></label>
</li>
</ul>
</div>

<script src="script.js"></script>
</body>
</html>

</html>
36 changes: 36 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
let todo_item = document.getElementById('todoInput');
let item1 = document.getElementById('item1');
let item2 = document.getElementById('item2');
let item3 = document.getElementById('item3');
let item4 = document.getElementById('item4');
let item5 = document.getElementById('item5');



function Add() {
if (todo_item.value === "") {
alert("Enter todo item")
} else {
alert(todo_item.value + " is added")
if (item1.value != "") {
if (item2 != "") {
if (item3 != "") {
if (item4 != "") {
if (item5 != "")
alert("Your ToDo List is Full")
item5.innerText = todo_item.value;
document.getElementsByClassName('checkmark:nth-child(5)').style.display = "block";
}
item4.innerText = todo_item.value;
document.getElementsByClassName('checkmark:nth-child(4)').style.display = "block";
}
item3.innerText = todo_item.value;
document.getElementsByClassName('checkmark:nth-child(3)').style.display = "block";
}
item2.innerText = todo_item.value;
document.getElementsByClassName('checkmark:nth-child(2)').style.display = "block";
}
item1.innerText = todo_item.value;
document.getElementsByClassName('checkmark:nth-child(1)').style.display = "block";
}
}
91 changes: 91 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
.container{
margin: auto;
padding: 25px;
width: 40%;
text-align: center;
height: 90vh;
background-color: rgb(219, 246, 246);
border-radius: 10px;
align-items: center;
font-size: large;
font-family: 'Courier New', Courier, monospace;
}
.container #todoInput{
width: 70%;
height: 40px;
border: none;
padding: 10px;
font-family: 'Courier New', Courier, monospace;
border-radius: 8px;
box-shadow: 1px 1px 3px #ccc;
font-size: 20px;
}
.container button{
width: 20%;
height: 60px;
border:1px solid #4b48482a;
padding: 10px;
font-family: 'Courier New', Courier, monospace;
font-weight: bold;
color: #545353;
background-color: blanchedalmond;
border-radius: 8px;
box-shadow: 1px 1px 3px #ccc;
font-size: 20px;
}
ul {
margin-top: 30px;
padding: 0;
}

/* Style the list items */
ul li {
cursor: pointer;
position: relative;
padding: 12px 8px 12px 40px;
list-style-type: none;
background: #eee;
font-size: 18px;
transition: 0.2s;
}

/* Set all odd list items to a different color (zebra-stripes) */
ul li:nth-child(odd) {
background: #f9f9f9;
}

/* Darker background-color on hover */
ul li:hover {
background: #ddd;
}

/* When clicked on, add a background color and strike out text */
ul li.checked {
background: #888;
color: #fff;
text-decoration: line-through;
}

/* Add a "checked" mark when clicked on */
ul li.checked::before {
content: '';
position: absolute;
border-color: #fff;
border-style: solid;
border-width: 0 2px 2px 0;
top: 10px;
left: 16px;
transform: rotate(45deg);
height: 15px;
width: 7px;
}

.checkmark {
display: none;
position: absolute;
top: 10%;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
}
54 changes: 54 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>

<head>
<title>
How to change the text of
a label using JavaScript ?
</title>
</head>

<body style="text-align:center;">

<h1 style="color:green;">
GeeksforGeeks
</h1>
<input id="ttt" type="text" width="200px" height="20px">
<h4>
Click on the button to change
the text of a label
</h4>

<label id="1">
</label> <br>
<label id="2">
Welcome to GeeksforGeeks
</label> <br>
<label id="3">
Welcome to GeeksforGeeks
</label>

<br>

<button onclick="myGeeks()">
Click Here!
</button>

<script>

function myGeeks() {
var label1 = document.getElementById("1");
var label2 = document.getElementById("2");
var label3 = document.getElementById("3");
var input = document.getElementById("ttt").value;

if (label1.innerHTML === "") {
label1.innerHTML = "item1: "+input;
} else {
label1.innerHTML = "else";
}
}
</script>
</body>

</html>