Protox39
IoT Systems Integrator
LEVEL 1
200 XP
In this tutorial we will create a Simple To Do List App using JavaScript. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. It can renders web pages in an interactive and dynamic fashion. It is widely used in designing a stunning website. This code can be used as your converter to your mathematical problem. So Let's do the coding...
Getting started:
This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
The Main Interface
This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.
Creating the Script
This code contains the script of the application. This code can add your task by adding in the data input to view the list of all your workloads. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js folder.
⚙ Live Demo
There you have it we successfully created a Simple To Do List App using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Download
Getting started:
This is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
The Main Interface
This code contains the interface of the application. To create this just write these block of code inside the text editor and save this as index.html.
- <!DOCTYPE html>
- <html
lang
=
"en"
>
- <head
>
- <meta
charset
=
"UTF-8"
name
=
"viewport"
content
=
"width=device-width, initial-scale=1"
/
>
- <link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"css/bootstrap.css"
/
>
- </
head
>
- <body
>
- <nav class
=
"navbar navbar-default"
>
- <div
class
=
"container-fluid"
>
- <a
class
=
"navbar-brand"
href
=
"https://sourcecodester.com"
>
Sourcecodester</
a
>
- </
div
>
- </
nav>
- <div
class
=
"col-md-3"
></
div
>
- <div
class
=
"col-md-6 well"
>
- <h3
class
=
"text-primary"
>
Javascript - Simple To Do List App</
h3
>
- <hr
style
=
"border-top:1px dotted #ccc;"
/
>
- <div
class
=
"form-inline"
>
- <label
>
Add Item</
label
>
- <input
type
=
"text"
id
=
"item"
class
=
"form-inline"
/
>
- <button
class
=
"btn btn-success"
onclick
=
"addItem()"
><span
class
=
"glyphicon glyphicon-plus"
></
span
></
button
>
- </
div
>
- <center
><h3
class
=
"text-primary"
>
My To Do List</
h3
></
center
>
- <ul
class
=
"list-group"
id
=
"list"
style
=
"word-wrap:break-word;"
/
>
- </
ul
>
- </
div
>
- </
body
>
- <script
src
=
"js/script.js"
></
script
>
- </
html
>
Creating the Script
This code contains the script of the application. This code can add your task by adding in the data input to view the list of all your workloads. To do this just copy and write these block of codes as shown below inside the text editor and save it as script.js inside the js folder.
- var
items =
document.getElementById
(
'list'
)
;
- var
list =
[
]
- function
displayList(
)
{
- var
data =
''
;
- if
(
list.length
>
0
)
{
- for
(
var
i=
0
;
i <
list.length
;
i++
)
{
- data +=
"<li class='list-group-item'><button class='pull-right' onclick='removeItem("
+
i+
")'><span class='glyphicon glyphicon-trash text-danger'></span></button>"
+
list[
i]
+
"</li>"
;
- }
- }
- document.getElementById
(
'list'
)
.innerHTML
=
data;
- }
- function
addItem(
)
{
- var
item =
document.getElementById
(
'item'
)
;
- var
val =
item.value
;
- if
(
val ==
""
)
{
- alert(
"Please enter something first!"
)
;
- }
else
{
- list.push
(
val.trim
(
)
)
;
- item.value
=
''
;
- displayList(
)
;
- }
- }
- function
removeItem(
item)
{
- list.splice
(
item,
1
)
;
- displayList(
)
;
- }
⚙ Live Demo
There you have it we successfully created a Simple To Do List App using JavaScript. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!
Download
You must upgrade your account or reply in the thread to view the hidden content.