vendredi 27 juin 2014

JS call to function in php page - syntax issue


Vote count:

0




HI i tring to call a js function in PHP file insi echo ""; and it's not working, if I call it without the echo it's work, what am I missing here ?


this way it's is work:



<a href='#' onClick='delfrmvbar("dlsyg","<?php echo $sgId;?>","<?php echo $sgId;?>")'>X</a>&nbsp;</span>


and this way is not (I tried without the - ' sign)



echo "<a href='#' onClick='delfrmvbar('dlsyg','$sgId','$sgId')'>X</a>&nbsp;</span>";


asked 1 min ago


1 Answer



Vote count:

0




Your single quotes are the issue because you use single quotes to wrap the onclick attribute, but then use them again around the arguments.



echo "<a href='#' onClick=\"delfrmvbar('dlsyg','$sgId','$sgId')\">X</a>&nbsp;</span>";


answered just now

MrCode

33.7k




Aucun commentaire:

Enregistrer un commentaire