-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask2_js
41 lines (36 loc) · 1.05 KB
/
Task2_js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function check_Solution(solution_str) //for checking the solution
{
box = false
highlight = false
for (i = 1; i <= solution_str.length; i++)
{
document.getElementById("square" + i).style.background = ""
if (document.getElementById("square" + i).value != solution_str.substr(i - 1, 1))
{
if (box == false)
{
highlight = confirm("The solution is incorrect. Would you like to highlight all incorrect entry?")
box = true
}
if (highlight == true)
{
document.getElementById("square" + i).style.border = "3px solid red"
document.getElementById("square" + i).style.background = "#ff8888"
}
}
}
if (box == true)
{
return false;
}
alert("Solution correct!")
return true
}
function fill_Solution(solution_str) //for filling in the solution
{
for (var i = 1; i <= solution_str.length; i++)
{
document.getElementById("square" + "" + i).style.background = ""
document.getElementById("square" + "" + i).value = solution_str.substr(i - 1, 1)
}
}