how do i echo this php variable inside innerhtml of javascript. I tried this but it isn't working. the function isn't called because if the php code
<a href="#"><img src="images/group3.png" alt="groups" border="0" title="Groups" onclick="return false" onmousedown="showGroups()"></a> <script type="text/javascript"> function showGroups() { _('groupModule').innerHTML = '<div id="groupWrapper"><div id="groupList"><h2>My Groups</h2><hr /><?php echo $mgList; ?><h2>All Groups</h2><hr /><?php echo $agList; ?></div></div>'; </script>
Please how do I fix this.
This depends on what the php variable is, if it is scalar value, you could echo it directly (but remember to escape the special chars which will break the javascript syntax).
And if the php variable is not scalar value (eg: array), then you can't echo it directly, you have to construct the valid javascript code use the variable.
No comments:
Post a Comment