so I'm trying to get javascript variable value into hidden input field and it sort of work, but I get default variable value from html5games.pingpong.js. If I set variable myVar = 0; I get 0 in an input field, but it's a game and I can't get the value of bestScore to increment.
html5games.pingpong.js
var pingpong = {
scoreA : 0, // score for player A
scoreB : 0, // score for player B
bestScore : 0
};
function movePaddles() {
pingpong.bestScore += 5;
}
PHP: test.php
<input id="score" type="hidden" name="bestScore">
<script>
document.getElementById('score').value = pingpong.bestScore;
</script>