A Form <form></form> is an HTML Tag that contain inner input elements that are filled by the user.
action="[url]" - Where the form data is sent
method="GET || POST" - HTTP Method to use when data is sent
enctype="multipart/form-data" - Used when sending files + text through the form
<input type="text"> - Text input
<textarea cols="[num]" rows="[rows]"></textarea> - Text input, but allows for multiple lines
<input type="checkbox" name="[checkboxGroupName]> - Common checkbox
<input type="radio" name="[radioGroupName]> - Just like the checkbox, but only allows for one selected element
<input type="file"> - File input
<label for="[inputID]">[Label]</label> - Recommended text element for any input item.
- HTML: Linguagem de Marcação de Hipertexto | MDN
When press a <button type="submit"> inside a form, the form triggers the action attribute even if it is empty. This causes the page to reload, and any JS function that would be executed is canceled.
To avoid that in the function of the addEventListener insert the following: