I would like to insert a javascript Alert into my action button

Asked

Viewed 479 times

0

first the action call to exclude

<?php
$aux = 0;
while($resultado = mysql_fetch_object($query))
{
$url_alterar = "form_alterar.php?cod=".$resultado->id;
$url_excluir = "excluir_cad.php?cod=".$resultado->id;
if ($aux % 2 == 0)

now the action button

<?="<td><a href=".$url_excluir."><img src='delete.jpg' height='35' width='35'></a></td>";?>

and I took this code here on the Internet

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
decisao = confirm("Clique em um botão!");
if (decisao){
alert ("Você Apagou o Registro,\n"+decisao);
} else {
alert ("Voce CANCELOU,\n"+decisao);
}
</SCRIPT>

I tried every way without success, I believe that the way it sends the variable to the system will not allow you to use this jscript resource. I have already tried to use direct in the action of the button but not surtiu result, nor on the page that is called or in the code explained above. I am asking for help because on 27/09 I present my work in college and would like to 'decorate' since everything works perfectly. Thank you for helping me! hugs

1 answer

1


Inline example:

<a href="delete.php" onclick="return confirm('Prosseguir com a ação?');">excluir</a>

To be more clear, for your case:

<?="<td><a href=".$url_excluir." onclick="return confirm('Prosseguir com a ação?');><img src='delete.jpg' height='35' width='35'></a></td>";?>

Then the excerpt <script>...</script> can erase.










I’m just going to suggest that you change a little

<td><a href="<?php echo $url_excluir;?>" onclick="return confirm('Prosseguir com a ação?');><img src='delete.jpg' height='35' width='35'></a></td>

Thus, PHP works less. The previous way is making PHP parse unnecessary data.

  • worked so -> onclick="Return confirm('Proceed with the action? You have chosen to Delete this Record')">

  • Because you put the <br><br><br><br><br><br><br><br><br>?

  • where? are you sure your question was directed to me?

  • to prevent additional observation from distracting attention.

Browser other questions tagged

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