PHP does not execute OnClick return confirm

-1

I'm having trouble executing javascript within the "echo" of PHP, I made some changes and the problem persists.

Here is the code I'm using:

 echo "<a href='excluir.php?id_edital=" . $pegar['id_edital'] . "; onClick='return confirm('Deseja realmente deletar o edital?')''><button id='submitdel'><img id='icon-trash' src='images/trash.png'> Excluir</button></a>";
    
asked by anonymous 30.05.2017 / 15:22

1 answer

3

In the part where onClick is, see that right after the word confirm you have another '(single quote), as it was used as the opening of the onClick action, you are closing it there. Put a double quotation mark (") with a slash before.

It would look like this:

echo "<a href='excluir.php?id_edital=" . $pegar['id_edital'] . "' onClick='return confirm(\"Deseja realmente deletar o edital?\")'><button id='submitdel'><img id='icon-trash' src='images/trash.png'> Excluir</button></a>";

Doing this fix, I believe it works now.

    
30.05.2017 / 15:28