javascript - JS call to function in php page - syntax issue -
hi tring call js function in php file using echo "";
, it's not working, if call without echo
it's work, missing here ?
this way it's work:
<a href='#' onclick='delfrmvbar("dlsyg","<?php echo $sgid;?>","<?php echo $sgid;?>")'>x</a> </span>
and way not (i tried without - ' sign)
echo "<a href='#' onclick='delfrmvbar('dlsyg','$sgid','$sgid')'>x</a> </span>";
your single quotes issue because use single quotes wrap onclick attribute, use them again around arguments.
example solution: use double quotes around attribute , escape.
echo "<a href='#' onclick=\"delfrmvbar('dlsyg','$sgid','$sgid')\">x</a> </span>";
this render html below, syntactically correct:
<a href='#' onclick="delfrmvbar('dlsyg','xx','xx')">x</a> </span>
Comments
Post a Comment