How do i modify the submit button so that when you click submit answer it goes to mysql database. I know i would need to use something like PHP but do not know how to.. Here is my code
what color is the grass?
<input type = "text" id = "answer">
<input type = "button" id = "time" onclick="answer()">
<script type = "text/javascript">
var n = 60; //seconds to answer
document.getElementById( 'time').value = "Answer in " + n + " seconds";
var i = setInterval('count()' , 1000);
var tooLate;
function count() {
tooLate = 0;
n--;
if(n >=0) {
document.getElementById( 'time').value = "Answer in " + n + " seconds";
}
else {
clearInterval(i);
alert("Too late!");
document.getElementById('answer').value = "";
tooLate = 1;
}
}
function answer() {
var correct = "green";
if (tooLate == 0) {
if(document.getElementById( 'answer').value == correct) {
clearInterval(i);
alert("Right Answer with " + n + " seconds remaining");
}
else{
clearInterval(i);
alert("Incorrect! The answer was " + correct);
}
}
}
</script>
Bookmarks