Reputation: 330
I have this delete link with a javascript who will promt Yes or No. But i got nothing promted. I can guess it´s the escaping from php etc. who puts stop in my code? The "onclick" uses "'". and the message uses "'". Is that the problem? And how do i solve it?
PHP/JS
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm('Are you sure to delete this ?');'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
Upvotes: 0
Views: 201
Reputation: 4637
Try this You forget to use \
in your code
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm(\"Are you sure to delete this ?\");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
Upvotes: 1
Reputation: 3425
You have problem with quotes. Pass it properly will resolved the problem.
Do like this:
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm(\"Are you sure to delete this ?\");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
Let me know for further query.
Upvotes: 1
Reputation: 25634
You did not escape the quotes around "Are you sure...". Escape them using a \
:
echo "<td><a href='time.php?id=".$row['id']."' onclick='return confirm(\"Are you sure to delete this ?\");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>";
This will output the following HTML:
<td><a href='time.php?id=XX' onclick='return confirm("Are you sure to delete this ?");'><span class='glyphicon glyphicon-remove text-danger'></span></a></td>
Upvotes: 2