<body onload="send()">
<input type="text" id="number1">
<br>
<input type="text" id="number2">
<br>
<input type="text" id="result">
<br>
<input type="button" id="send" onclick="send()" value="проверить">
<script>
function send(){
var elem_1 = document.getElementById("number1");
var elem_2 = document.getElementById("number2");
var result = parseInt(elem_1.value) + parseInt(elem_2.value);
var elem_3 = document.getElementById("result");
if (result == parseInt(elem_3.value)) alert("правильно");
if (result != parseInt(elem_3.value) && elem_3.value != "" ) alert("неправильно");
elem_1.value = Math.floor(Math.random() * Math.floor(1000));
elem_2.value = Math.floor(Math.random() * Math.floor(1000));
}
</script>
</body>
|