i couldn’t add data from my form inputs to the firestore collection and i can’t find out what is the problem here

Your problem most probably comes from the fact that your form is submitted before the Firebase set() method is triggered.

As a matter of fact, you declare your button as follows:

<form id="add-location-form">
    // ...
    <button id="addLocation-btn" onclick="storeData()">Add</button>

i.e. without any type attribute.

As detailed in the W3 specification on button types, “the missing value default is the Submit Button state” and “if the type attribute is in the Submit Button state, the element is specifically a submit button”.

So, if you add a button type to your button, as follows, it should solve your problem.

<button type="button" id="addLocation-btn" onclick="storeData()">Add</button>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top