I am unable to send a string from php page to java script page. I am storing a string in a php variable and I want to send this value to java script page on image icon click. Here is the source code:
timetrack.php
$activityid = $getResult->fields('ACTIVITY_ID'); // Now consider the value in $activityid is "AG001"
<img src="phpimages/tt_comment.gif" title="Add remarks" alt="add remarks icon" style="border:none;cursor:pointer;margin:0 0 0 5px" onclick="showRemarks('.$activityid.');" id="remarksadd"></img>
userfn.js
function showRemarks(actid)
{
alert(actid);
document.getElementById("tt_comment_section").value = actid;
}
Here the function showRemarks(actid) itself is not calling.
FYI: If I store integer value(ex: 256487) in $activityid variable, the function is calling successfully and alert is showing the result. Problem coming with the string alone. I have tried with different syntaxes like
onclick="showRemarks("'.$activityid.'");"
onclick="showRemarks('".$activityid."');"
onclick="showRemarks(".$activityid.");"
onclick="showRemarks($activityid);"
but no one giving result. Please give me the solution.
Thanks.