text: Q:
  
  Problem with adding a new document in Firestore
  
  I have a collection in Firestore:Collection(Models) -> Document(Fan) -> Collection(Assets)
  And I want to add a new document to the collection(Assets)
  Here's the HTML code:
  <form>
   <input type="text" id="asset_id" />
   <button type="submit" id="submit">Submit</button>
  </form>
  
  Javascript code:
  const assets = firestore.collection("Models").doc("Fan").collection("Assets");
  
  document.querySelector('#submit').addEventListener('click', () => {
  var asset_id = document.getElementById("asset_id").value;
   addAsset(asset_id);
  });
  
  const addAsset = asset => {
      assets.add({asset_type: asset});
  };
  
  but the code doesn't work and nothing is added to the collection 
  
  A:
  
  By assigning the submit type to your button, your form is submitted before the Firebase method is triggered.
  Changing the type to button, as follows, should do the trick:
  <form>
   <input type="text" id="asset_id" />
   <button type="button" id="submit">Submit</button>
  </form>
  
  See the W3 specification for more detail.
  
  