I have a page downloading a random MP3 file with every update. The user must guess the name based on the sound by entering a text form. I want to check their input against a saved row and refresh the page if it is fixed. Otherwise, I would not give them the wrong warning and stayed on the same page so that they can again assume:
<div class="ui-widget" align="center">
<form method="post" action="" class="answer_box" onsubmit="return submit();">
<p>Which hero is it? <input id="tags" name="guess" /></p>
<script>
var key = <?php echo json_encode($rand_key) ?>;
var info = document.getElementById("guess").value;
function submit() {
if (key==info){
alert('Correct!');
return true;
}
else {
alert('Incorrect!');
returnToPreviousPage();
return false;
}
}
</script>
</form>
</div>
Currently, it transfers information to a new page, regardless of input. Javascript warnings are also not displayed (I suspect they are showing, but the page then refreshes and they disappear). The key variable is the key to the random value of the PHP array, and the information must be entered by the user.