I am storing a string value in one php variable.I want to send this value to a function on image click. Here is code
userfn.php
$actvitycode = "AG001";
<img src="phpimages/addicon.gif" onclick="showData('.$actvitycode.')"></img>
getdata.js
function showData(actcode)
{
alert(actcode);
document.getElementById("tasklist").value = actcode;
}
Problem is, on image click the function is not calling. FYI: If I store integer value (ex:2342) in $actvitycode the function is successfully called and alert is showing the result. The problem with the string value only. I tried with several syntaxes like
onclick="showData("'.$actvitycode.'")"
onclick="showData($actvitycode)"
but no one syntax is giving result. Please provide me correct syntax.