Passing variables from php to javascript
From MyWiki
https://stackoverflow.com/questions/23740548/how-to-pass-variables-and-data-from-php-to-javascript
<!-- snip --> <div id="dom-target" style="display: none;"> <?php $output = "42"; //Again, do some operation, get the output. echo htmlspecialchars($output); /* You have to escape because the result will not be valid HTML otherwise. */ ?> </div> <script> var div = document.getElementById("dom-target"); var myData = div.textContent; </script> <!-- snip -->