JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<body>
<form id="form">
<input name="input-data"/>
<button type="submit" name="action" value="first">Submit</button>
<button type="submit" name="action" value="second">Another Submit</button>
</form>
<script>
function handleSubmit(event) {
event.preventDefault(); // don't have the browser refresh on submit
const formData = new FormData(event.target);
for (var pair of formData.entries()) {
console.log(pair[0]+ ' ==> ' + pair[1]);
}
}
const form = document.getElementById('form');
form.addEventListener('submit', handleSubmit);
</script>
</body>
</html>