ItsLeoTM
Cyber Evidence Collector
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
400 XP
In this tutorial we will create a Autofill Inputs By Dragging using JavaScript. JavaScript is a scripting or programming language that allows you to implement complex things on web pages. It is a text-based programming language meant to run as part of a web-based application. It is an interpreted programming language that has a capabilities of Object-Oriented. So Let's do the coding...
Getting started:
First you have to download bootstrap framework, 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 drag and drop the data into the corresponded input form. 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.
There you have it we successfully created a Autofill Inputs By Dragging 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:
First you have to download bootstrap framework, 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
=
"navabr 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 - Autofill Inputs By Dragging</
h3
>
- <hr
style
=
"border-top:1px dotted #ccc;"
/
>
- <div
class
=
"col-md-6"
>
- <h4
id
=
"PHP"
draggable=
"true"
ondragstart=
"drag(event)"
>
PHP</
h4
>
- <h4
id
=
"JavaScript"
draggable=
"true"
ondragstart=
"drag(event)"
>
JavaScript</
h4
>
- <h4
id
=
"C++"
draggable=
"true"
ondragstart=
"drag(event)"
>
C++</
h4
>
- <h4
id
=
"C#"
draggable=
"true"
ondragstart=
"drag(event)"
>
C#</
h4
>
- <h4
id
=
"Python"
draggable=
"true"
ondragstart=
"drag(event)"
>
Python</
h4
>
- </
div
>
- <div
class
=
"col-md-6"
>
- <div
class
=
"form-group"
>
- <input
class
=
"form-control"
type
=
"text"
id
=
"data"
ondrop=
"drop(event)"
ondragover=
"dragOver(event)"
readonly
=
"readonly"
/
>
- </
div
>
- <center
><button
class
=
"btn btn-primary"
onclick
=
"submit();"
><span
class
=
"glyphicon glyphicon-save"
></
span
>
Submit</
button
>
<button
class
=
"btn btn-success"
onclick
=
"reset();"
><span
class
=
"glyphicon glyphicon-refresh"
></
span
>
Clear</
button
></
center
>
- <br
/
>
- <div
id
=
"result"
></
div
>
- </
div
>
- </
div
>
- <script
src
=
"js/script.js"
></
script
>
- </
body
>
- </
html
>
Creating the Script
This code contains the script of the application. This code can drag and drop the data into the corresponded input form. 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.
- function
dragOver(
e)
{
- e.preventDefault
(
)
;
- }
- function
drop(
e)
{
- e.preventDefault
(
)
;
- var
data =
e.dataTransfer
.getData
(
"data"
)
;
- document.getElementById
(
'data'
)
.value
=
data;
- }
- function
drag(
e)
{
- e.dataTransfer
.setData
(
"data"
,
e.target
.id
)
;
- }
- function
submit(
)
{
- var
data =
document.getElementById
(
'data'
)
.value
;
- if
(
data !=
""
)
{
- document.getElementById
(
'result'
)
.innerHTML
=
data;
- }
- }
- function
reset(
)
{
- document.getElementById
(
'result'
)
.innerHTML
=
""
;
- document.getElementById
(
'data'
)
.value
=
""
;
- }
There you have it we successfully created a Autofill Inputs By Dragging 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 hidden text.