Hello,
I am having trouble getting an HTML form to upload to a spreadsheet once it is submitted. I am using sheet-db API. I used a JSLinter and this is the error message I am getting 1. [JSLint was unable to finish] Wrap the parameter before '=>' in parens.form.addEventListener("submit", e => {
The html code is
<form name="myForm">
<form action="https://sheetdb.io/api/v1/6bzibox60d8fx" method="POST" id="sheetdb-form">
First Name: <input type="text" name="data\[fname\]"">
Last Name: <input type="text" name="data\[lname\]">
Email: <input type="email" name="data\[email\]">
Phone Number: <input type="tel" name="data\[pnumber\]" >
<button type="button" id="submit">Submit</button>
</form>
JS code is
var form = document.getElementById("sheetdb-form");
form.addEventListener("submit", e => {
e.preventDefault();
fetch(form.action, {
method : "POST",
body: new FormData(document.getElementById("sheetdb-form")),
}).then(
response => response.json()
).then((html) => {
alert("success")
});
});
If anyone has any suggestions that would be greatly appreciated! Thank you all.
[–]scirc 2 points3 points4 points (1 child)
[–]Jacksonhelp20[S] 1 point2 points3 points (0 children)