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

214
Vistas
how can I submit my form and after submit i want to update doc to firestore database

I have tried the following but it only works either in submitting the form or updating to the Firestore database.

I want to submit my form first then after the form is submitted I want to update a doc in Firestore.

 <form action='/search' method="post">
                                    
    <input type="text"  value="{{ query }}"/>
    <input type="submit" value="submit"/>

</form>

and my javascript code

 <script>
function update()
{
    
    db = firebase.firestore()
    db.collection("users").doc(userid).update({
    "number": 2,

})
.then(() => {
    console.log("Document successfully written!");
    })
.catch((error) => {
    console.error("Error writing document: ", error);
    
    });
}
</script>


    
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Intercept the form submit and then programmatically submit the form via an asynchronous request (so that your current page is not reloaded). After this, call the code to update your db.

Refer to this article for sample code on how to intercept your form submit and then do an asynchronous request. Your call to update your db will go into the bit that says .done(function (data) {

about 4 years ago · Juan Pablo Isaza Denunciar
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