Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
Identifying which form sends the POST method

I have been trying to achieve something so that when I receive the POST I know which form sends it

I checked the form attributes and it doesn't seem to be able to have an ID or something similar, I can't think of anything functional inside the router.post() either and what little I have come up with hasn't worked

This is the form

<form action="/dashboard/" method="POST">
   <div class="form-group">
      <button class="btn btn-success">Do!</button>
   </div>
</form>

I want to know if the FORM that sends the post is that one.

This is the way I receive the POST in its respective .js file

router.post("/", async (req, res) => { . . .

I have tried testing some things with req, without any luck

As a little relevant information, I'm using Bootstrap 5, I don't have my own styles or classes.

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Add a hidden input field to the form like

<input type="hidden" id="formName" name="formName" value="myDashboardForm">

Then access the "formName" inside the POST variables on the Backend.

about 4 years ago · Juan Pablo Isaza Relatório

0

A simple approach would be to include a hidden input

<form action="/dashboard/" method="POST">
   <div class="form-group">
      <button class="btn btn-success">Do!</button>
   </div>
   <input type="hidden" id="formId" name="formId" value="formType1">
</form>

Then you should be able to get the formType in req.body.formId

about 4 years ago · Juan Pablo Isaza Relatório

0

Add the input field to be hidden and acess using the form id

<form action="/dashboard/" method="POST">
   <div class="form-group">
      <button class="btn btn-success">Do!</button>
   </div>
   <input type="hidden" id="formId" name="formId" value="formType1">
</form>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda