<html>
<head> </head>
<body>
<input type="button" value = "начать" onclick="button_1_clicked()">
<input type="button" value = "я запомнил" onclick="button_2_clicked()">
<input type="button" value = "проверить" onclick="button_3_clicked()">
<div id="div_1">запомни цвет</div>
<br>
<select id="selcolor_1">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_2">запомни цвет</div>
<br>
<select id="selcolor_2">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_3">запомни цвет</div>
<br>
<select id="selcolor_3">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_4">запомни цвет</div>
<br>
<select id="selcolor_4">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_5">запомни цвет</div>
<br>
<select id="selcolor_5">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_6">запомни цвет</div>
<br>
<select id="selcolor_6">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_7">запомни цвет</div>
<br>
<select id="selcolor_7">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_8">запомни цвет</div>
<br>
<select id="selcolor_8">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_9">запомни цвет</div>
<br>
<select id="selcolor_9">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<br>
<br>
<div id="div_10">запомни цвет</div>
<br>
<select id="selcolor_10">
<option value="1">красный</option>
<option value="2">зеленый</option>
<option value="3">голубой</option>
</select>
<script>
var arraycolors = [];
function button_1_clicked()
{
for (i = 0; i < 10; i++)
{
var randomcolor = Math.floor(Math.random()*3);
if (randomcolor == 0)arraycolors[i] = "red";
if (randomcolor == 1) arraycolors[i] = "green";
if (randomcolor == 2) arraycolors[i] = "blue";
}
var element_1 = document.getElementById("div_1");
var element_2 = document.getElementById("div_2");
var element_3 = document.getElementById("div_3");
var element_4 = document.getElementById("div_4");
var element_5 = document.getElementById("div_5");
var element_6 = document.getElementById("div_6");
var element_7 = document.getElementById("div_7");
var element_8 = document.getElementById("div_8");
var element_9 = document.getElementById("div_9");
var element_10 = document.getElementById("div_10");
element_1.style.color = arraycolors[0];
element_2.style.color = arraycolors[1];
element_3.style.color = arraycolors[2];
element_4.style.color = arraycolors[3];
element_5.style.color = arraycolors[4];
element_6.style.color = arraycolors[5];
element_7.style.color = arraycolors[6];
element_8.style.color = arraycolors[7];
element_9.style.color = arraycolors[8];
element_10.style.color = arraycolors[9];
}
function button_2_clicked()
{
var element_1 = document.getElementById("div_1");
var element_2 = document.getElementById("div_2");
var element_3 = document.getElementById("div_3");
var element_4 = document.getElementById("div_4");
var element_5 = document.getElementById("div_5");
var element_6 = document.getElementById("div_6");
var element_7 = document.getElementById("div_7");
var element_8 = document.getElementById("div_8");
var element_9 = document.getElementById("div_9");
var element_10 = document.getElementById("div_10");
element_1.style.color = "black";
element_2.style.color = "black";
element_3.style.color = "black";
element_4.style.color = "black";
element_5.style.color = "black";
element_6.style.color = "black";
element_7.style.color = "black";
element_8.style.color = "black";
element_9.style.color = "black";
element_10.style.color = "black";
}
function button_3_clicked()
{
var element_1 = document.getElementById("selcolor_1");
var element_2 = document.getElementById("selcolor_2");
var element_3 = document.getElementById("selcolor_3");
var element_4 = document.getElementById("selcolor_4");
var element_5 = document.getElementById("selcolor_5");
var element_6 = document.getElementById("selcolor_6");
var element_7 = document.getElementById("selcolor_7");
var element_8 = document.getElementById("selcolor_8");
var element_9 = document.getElementById("selcolor_9");
var element_10 = document.getElementById("selcolor_10");
var selectarray = [];
if (element_1.value == "1") selectarray[0] = "red";
if (element_1.value == "2") selectarray[0] = "green";
if (element_1.value == "3") selectarray[0] = "blue";
if (element_2.value == "1") selectarray[1] = "red";
if (element_2.value == "2") selectarray[1] = "green";
if (element_2.value == "3") selectarray[1] = "blue";
if (element_3.value == "1") selectarray[2] = "red";
if (element_3.value == "2") selectarray[2] = "green";
if (element_3.value == "3") selectarray[2] = "blue";
if (element_4.value == "1") selectarray[3] = "red";
if (element_4.value == "2") selectarray[3] = "green";
if (element_4.value == "3") selectarray[3] = "blue";
if (element_5.value == "1") selectarray[4] = "red";
if (element_5.value == "2") selectarray[4] = "green";
if (element_5.value == "3") selectarray[4] = "blue";
if (element_6.value == "1") selectarray[5] = "red";
if (element_6.value == "2") selectarray[5] = "green";
if (element_6.value == "3") selectarray[5] = "blue";
if (element_7.value == "1") selectarray[6] = "red";
if (element_7.value == "2") selectarray[6] = "green";
if (element_7.value == "3") selectarray[6] = "blue";
if (element_8.value == "1") selectarray[7] = "red";
if (element_8.value == "2") selectarray[7] = "green";
if (element_8.value == "3") selectarray[7] = "blue";
if (element_9.value == "1") selectarray[8] = "red";
if (element_9.value == "2") selectarray[8] = "green";
if (element_9.value == "3") selectarray[8] = "blue";
if (element_10.value == "1") selectarray[9] = "red";
if (element_10.value == "2") selectarray[9] = "green";
if (element_10.value == "3") selectarray[9] = "blue";
var match = 0;
for (i = 0; i < 10; i++)
{
if (arraycolors[i] != selectarray[i]) match = match + 1;
}
if (match == 0)
alert("замечательная память")
else
alert ("сделано ошибок " + match);
}
</script>
</body>
</html>
|