Make Submit with <a> and appear JS dialog

Asked

Viewed 90 times

0

<form action="" name="Insert" method="post" onsubmit="alert(1);  return false;">


<a href="#" onclick="javascript:document.Insert.submit()" type="submit" >Eliminar</a>

Good people, here’s the thing, when I do Submit it just does Submit without appearing the alert to confirm, I tried otherwise as:

<form action="" name="Insert" method="post" onsubmit="alert(1);  return false;">


<a href="#" onclick="alert(1);  return false; javascript:document.Insert.submit()" type="submit" >Eliminar</a>

In this code I just presented, I only see the dialog, but I can only cancel, I click on "OK" it does nothing, nor closes the dialog..

1 answer

1


If you want to do Ubmit and display the dialog, you will have to create a Js function to control the form’s Ubmit by clicking on the link. In this idea:

function submeteForm(){
alert("Foi submetido!!");
document.getElementById("Insert").submit();
}

Your Form:

<form action="" name="Insert" id="Insert" method="post">
<a href="#" onclick="submeteForm()">Eliminar</a>

Now if you just want to display a confirmation window, it’s simpler still, just add in your link:

 <a href="#" onclick="return confirm('TEM CERTEZA?')" >Eliminar</a>
  • does nothing.. and I’m talking about your first example which is what it takes

  • I already solved, but I only got thanks so, THANK YOU

Browser other questions tagged

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