-2

For a jQuery Datatables grid, I'm trying to figure out how I can add a onclick event to the delete link (when I need a double quoted variable string with single and double quotes inside it).

onlick="return confirm('are you sure?')"

$nestedData[] = "<a href=users_delete.php?id=" . $row['id'] . "> Delete </a>";  

Since an onlick event needs both single and double quotes to declare it, how to you get an onclick event added to a HREF that's stored in a variable?

thanks!

Reno
  • 2,924
  • 9
  • 39
  • 68

1 Answers1

1

You are looking for character escaping:

$a = "this is \"quoted\"";
$b = 'this is \'quoted\'';
$c = 'this is "quoted"';
$d = "this is 'quoted'";
Marcin Orlowski
  • 68,918
  • 10
  • 117
  • 136
  • Awesome thinks. I totally forgot about escape characters and forgot to use that as a search term. Doh! Thanks! – Reno Aug 17 '17 at 19:22