Passing Javascript variables to PHP
It's easy to get Javascript variable into PHP.
What you have to do is follow below code.
Result will be:
Printed My JS variable into PHP: Carrot
What you have to do is follow below code.
//in script block
var veg = 'Carrot';
//in php block
$veg = "<script type='text/javascript'>document.write(veg);</script>";
echo 'Printed My JS variable into PHP: '.$veg;
Result will be:
Printed My JS variable into PHP: Carrot
Comments
Post a Comment