Created
June 28, 2023 16:49
-
-
Save techb/d9fb80fe446efcaa22fc8fce8532c26a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Yoink: https://www.javascripttutorial.net/web-apis/javascript-formdata/ | |
const btn = document.querySelector('#submit-btn-id'); | |
const form = document.querySelector('#my-form-id'); | |
btn.addEventListener('click', (e) => { | |
// prevent the form from submitting | |
// or uncomment the debugger statment below for a breakpoint | |
// if needing to also send the data for testing | |
e.preventDefault(); | |
// show the form values | |
const formData = new FormData(form); | |
const values = [...formData.entries()]; | |
console.log(values); | |
// comment out the preventDefault and uncomment below to sue breakpoints instead | |
// debugger; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment