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>&nbsp;</span>  

and way not (i tried without - ' sign)

echo "<a href='#' onclick='delfrmvbar('dlsyg','$sgid','$sgid')'>x</a>&nbsp;</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>&nbsp;</span>"; 

this render html below, syntactically correct:

<a href='#' onclick="delfrmvbar('dlsyg','xx','xx')">x</a>&nbsp;</span> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -