javascript - pass JS variable to php echo statement -
i trying pass js variable php echo statement.
here code
<?php print '<a href="thistest.html?id=my_js_value">test</a>'; ?>
how can that
i test , works how can write value within href
alert(myvalue); ";
this impossible temporal point of view.
when php code run, there no javascript. page not yet loaded browser. there no javascript engine being run. there no javascript variables. time browser renders page, server code has done job.
with said, can render html refers javascript function. example:
<?php print '<a href="javascript:donav(\'thistest.html\');">test</a>'; ?>
then, implement donav
accordingly:
function donav(url) { location.href = url + '?id=' + my_js_value; // navigate new url javascript variable }
Comments
Post a Comment