3
my question is this::
<!DOCTYPE html>
<html dir="ltr" lang="pt-BR">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Joguinho</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="container">
<?php
$contador = 0;
$random1 = (rand(1,10));
$random2 = (rand(1,10));
$resultado = $random1 * $random2;
$contador++;
echo("<div id='contador'>".$contador."/10"."</div>");
echo("<div id='campo'>".$random1."x".$random2."</div>");
?>
<input id="digiteValor" type="text" />
<button id="enviar" onclick="chama()">Enviar</button>
<div id="certoOuErrado"></div>
</div>
</body>
<script type="text/javascript">
function chama(){
var valorDigitado = document.getElementById('digiteValor').value;
var resultado = "<?php echo $resultado; ?>";
//var correto = "<div id='correto'></div>";
//var incorreto = "<div id='incorreto'></div>";
if(resultado == valorDigitado){
document.getElementById('certoOuErrado').innerHTML = "CORRETO";
//document.getElementById('certoOuErrado').innerHTML = correto;
} else {
document.getElementById('certoOuErrado').innerHTML = "INCORRETO";
//document.getElementById('certoOuErrado').innerHTML = incorreto;
}
}
</script>
</html>
that’s the code I’ve made so far
the idea is for the boy to enter the value, wait a while to check if the answer is correct or incorrect. I have an accountant who should count 10 moves, it’s like a loop. Can you refresh the screen and update this data until you make 10 moves? You have to take a little time to answer. for example: has 4seg to answer, after the time is over is checked if the entered value is correct or incorrect, then goes to next iteration.
To execute a code from there to X milliseconds, use
setTimeout(função, X);
- or to execute a code each X milliseconds, usesetInterval(função, X);
. In this function you can update the value of any element, usinggetElementById
(that I saw in your code that you know how to use). Try this, and if you still have difficulties with logic, I’ll come back to give a more complete answer.– mgibsonbr
P.S. I suggest [Edit] the question and bring the relevant code here, instead of just putting a link pro Pastebin (the full code you leave there anyway, only brings relevant snippets to the question).
– mgibsonbr