Do submit with and appear JS dialog

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


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

<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 that I just presented, I only see the dialog, but I can only cancel it, I click "ok" it does nothing or close the dialog ..

    
asked by anonymous 25.04.2015 / 17:01

1 answer

1

If you intend to submit and display the dialog, you will have to create a function in Js to control the form submit 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 only want to display a confirmation window, it's even simpler, just add it to your link:

 <a href="#" onclick="return confirm('TEM CERTEZA?')" >Eliminar</a>
    
25.04.2015 / 17:28