Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
How to upload data to firebase by clicking button in form tag

Hi I was struggling for this issue for hours, and need any experts to help!

I'm trying to upload my data to Firebase database by clicking button in form, but it's not working... I think the problem occurs when I click the button in the form tag. Should I use addEventListener'click' instead of 'submit'?

Please refer to the codes below. Truly appreciated!

HTML

   <div class="container">
    <div class="row">
      <form id="question-form" class="padT100">
        <div class="col-md-5 col-sm-6 col-xs-12">
          <div class="post-gray">
            <input
              id="name"
              type="text"
              name="full name"
              value=""
              placeholder="성함"
            />
            <input
              id="contact"
              type="text"
              name="contact"
              value=""
              placeholder="연락처"
            />
            <input
              id="store"
              type="text"
              name="store"
              value=""
              placeholder="지점명"
            />
          </div>
        </div>
        <div class="col-md-7 col-sm-6 col-xs-12">
          <div class="post-gray marT20">
            <textarea
              id="question-detail"
              placeholder="문의 내용"
              rows="5"
              cols="50"
            ></textarea>
          </div>
        </div>
        <div class="col-md-12 col-sm-6 col-xs-12 marT30">
          <button type="submit" class="itg-button-3" id="send-question">전송</button>
        </div>
      </form>
    </div>
  </div>

Javscript

<script>
  const db = firebase.firestore();
  const form = document.getElementById('question-form')
  form.addEventListener('submit', (e) => {
    const singleQuestion= {
      성함: $('#name').val(),
      연락처: $('#contact').val(),
      지점명: $('#store').val(),
      문의내용: $('#question-detail').val(),
      날짜: new Date()}

    e.preventDefault();
    db.collection('questions').add(singleQuestion)
  });
</script>

Thanks in advance!

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda