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>";
asked Mar 5, 2015 at 12:21
d00rman
3301 gold badge6 silver badges15 bronze badges
-
Same sort of question posted 35 minutes ago stackoverflow.com/questions/28877278/…NewToJS– NewToJS2015年03月05日 12:30:32 +00:00Commented Mar 5, 2015 at 12:30
3 Answers 3
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>
answered Mar 5, 2015 at 12:23
blex
25.7k6 gold badges49 silver badges78 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
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.
answered Mar 5, 2015 at 12:24
Anand Solanki
3,4254 gold badges19 silver badges27 bronze badges
Comments
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>";
answered Mar 5, 2015 at 12:26
I'm Geeker
4,6575 gold badges25 silver badges42 bronze badges
Comments
default