How to make a Submit with <button type="button">?

Asked

Viewed 1,043 times

0

I have created some and need them to perform the same functions (with database) of how to register, change, etc. Can anyone help me or explain how to do this?

Thank you !

  • 1

    created some what? Some forms?

  • I have a form. I need to change, consult, delete and register. However, when I click on some other outside of "register", this sending me to the registration form again

  • how is your <a href="tela" >Tela </a>?

1 answer

3


With javascript you can click on the button to invoke the form’s Submit event:

HTML:

<form id="meu_form">
  <button id="enviar" type="button"> Enviar </button>
</form>

Javascript

document.getElementById('enviar').addEventListener('click', function() {
  document.getElementById('meu_form').submit();
});
  • Thank you for your answer, clarified a lot. However, another question arose. I need to make a select in a table, but when I click on that button, it’s sending me to my screen form. (and I don’t want that) Remembering that my screen is divided by tabs, so do not want to change. Customer specification

  • I have a form. I need to change, consult, delete and register. However, when I click on some other outside of "register", this sending me to the registration form again

  • Interesting your doubts but it is outside the scope of this question @Rodrigocaio, you can ask another question detailing this just commented, because if you change this will invalidate my answer. If possible detail better what is searched and post the relevant code snippets.

  • Buddy, I got the problem solved. In fact, I was putting the <form> before my tab tags, so it was occupying mine (.php) as a whole. I put it inside the tab, and solved the problem. Thank you very much ! Now how do I close this question?

  • If my answer answered, just mark as accepted (there is a sign of positive, just below the count of votes in it) =]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.