how to store a js method call to a php variable code example
Example 1: how to use javascript variable in php
<script>
var p1 = "success";
</script>
<?php
echo "<script>document.writeln(p1);</script>";
?>
Example 2: how to use php variable in javascript file
alert("color: " + color);