Hey guys I am not a web developer by any means (as you can tell), I am just an IT guy who got roped into remaking the company website. Its pretty simple just one page with some info and a contact form. Right now I have this code (well shortened, I just included one of the 9 fields
<div id="contactFormContainer">
<form id="" class="grid-form" method="POST">
<input class="half" name="contactFirstName" placeholder="First Name" />
<button>Submit</button>
</form>
</div>
And that calls this bit of javascript
if (Astro.request.method === "POST") {
try {
const data = await Astro.request.formData();
const name = data.get("contactFirstName");
console.log(name)
} catch (error) {
if (error instanceof Error) {
console.error(error.message);
}
}
}
Whenever you hit submit on the actual web page it just refreshes, and doesn't actually print anything to the console (well maybe it is, since it clears the console on refresh anyways)
I did try reading the documentation and I found (a couple of)[https://github.com/withastro/astro/issues/9488] (questions)[https://stackoverflow.com/questions/19454310/stop-form-refreshing-page-on-submit] online but I couldn't get any of them to work :(
Any ideas? Again, I'm not a web developer so sorry if this is a really dumb question.