1
I have the following situation:
a form and two buttons (Submit), and the button (Register new point of sale) will register the data in the database and re-load the registration page so that the user fills the data of a new point of sale, the other button (Finish registration) will register the data in the database and should be directed to the registration completion screen.
The problem is that I can not make the moment that the button (Finish the registration) is clicked it make the record of the data in the database.
I am developing in pure Javascript and am starting....
Follow the codes:
  <form method="post"> 
    <!-- BOTÕES DE CADASTRO-->
    <div class="button">
      <input type="submit" value="Cadastrar novo ponto de venda" name="send" value="new-register" id="Cadastrar novo ponto de venda" class="new-register" onclick="sendform(this.id)"/>
      <input type="submit" value="Finalizar o cadastro" name="send" value="register" id="Finalizar o cadastro" class="register" onclick="sendform(this.id)" />         
    </div>
  </form>
function sendform(idButton) {
    let form = document.forms[0];
    if (idButton == "Cadastrar novo ponto de venda") {
        form.action = "/register-pdv";
    }
    if (idButton == "Finalizar o cadastro") {
        form.action = "/registered-pdv";
    }
}
Thanks for your help.
Abs
Is there any reason
2 input type submit? Why not just use the html tagbutton– Danizavtz
In the form, I need two buttons one to register only one store and another to register more stores. When I came across the problem I researched and saw that they used two inputs instead of the button. As I’m starting out, it may not be the best option. Feel free to suggest, as I’m learning...
– Newton