Skip to content

Commit b8a09f5

Browse files
authored
init
1 parent 437ed7a commit b8a09f5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
# Get-Form-Data-with-JavaScript
22
get data from a FORM with JavaScript
3+
4+
5+
// getting the Form element and listener it
6+
document.querySelector('form')
7+
.addEventListener('submit', e => {
8+
// stop the default functions
9+
e.preventDefault()
10+
// store the data in a variable, create new FormData to intruduce the form target data
11+
const data = Object.fromEntries(
12+
new FormData(e.target)
13+
)
14+
// show the Object in a console log
15+
console.log(JSON.stringify(data))
16+
})

0 commit comments

Comments
 (0)