0

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>";
1

3 Answers 3

2

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>
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

1

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>";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.