i'm trying to echo the following function add() in HTML
'<a onclick="add('.$row["x"].','.$row["y"].')" href="javascript:void(0)">'
The function is not getting invoked. How should i implement it correctly?
This
echo '<a onclick="add('.$row["x"].','.$row["y"].')" href="javascript:void(0)">';
will gives you
<a onclick="add(a,b)" href="javascript:void(0)">
You need to add single quotes if you are passing strings to your function, like this
echo '<a onclick="add(\''.$row["x"].'\',\''.$row["y"].'\')" href="javascript:void(0)">';
Then in your document you will get
<a onclick="add('a','b')" href="javascript:void(0)">