I am playing with PHP and Javascript. Also I am trying to find all possible ways to pass javascript variable into php variable in the same php file. So far, I have found two possible ways. One is well known to everybody which is ajax (i,e calling another php file). But it could not solve my problem easily. Another solution that I have figured out is utilizing COOKIE/SESSION. Here is my simple code example: It will alert 5 to 10. Javascript variable value 5 is passing inside php variable =>
<div id="one">5</div>
<script>
var vall = document.getElementById("one").innerHTML;
document.cookie = "val="+vall;
alert('<?php for($i=$_COOKIE["val"];$i<=10;$i++){echo $i;} ?>');
</script>
Do you have any other alternate or better solution?