To stop the form from reloading when you click button you need to stop the event bubbling up through to the form by doinf something like this;
<body onclick="alert(`the bubbling doesn't reach here`)">
<button onclick="event.stopPropagation()">Click me</button>
</body>
See this article;
/bubbling-and-capturing[
^]