What I'm trying to make is a check list for a lotto game, which is a sort of bingo for my family. I will first try to explain what the check list does and why, excuse my technical english, I'm dutch, so some words can be wrong :)
I have a list with a couple of people who play the lotto/bingo game. All players pick 10 numbers and once a week there is a draw of 6 numbers, I try to explain step by step what the code has to do.
1 - 10 people's numbers should be checked
2 - 6 numbers are added every week which should be compared with the numbers of the people.
3 - font should be colored green when there is a match.
4 - font should stay red when there is no match
Here is the code I have this far, a live version is at the link.
The code beneath works great, but the problem is that the code is designed to compare var A with var B, this is a bottleneck, because it's a 1 on 1 action. I can't add more people without adding a Draw day.
Now my question. What should be done to add more people (A1, A2, A3 etc etc.) without adding a draw date like B2.
I hope this is clear enough. :)
<script type = "text/javascript">
var a1 = ["2","3","8","12","23", "37", "41", "45", "48"]
var a2 = ["2","14","3","12","24", "37", "41", "46", "48"]
var b1 = ["2","5", "11","16","23","45", "46"];
var b2 = ["1","23", "11","14","23","42", "46"];
for (var i = 0; i< a1.length; i++)
{
for (var j = 0; j< b1.length; j++)
{
if (a1[i] == b1[j])
{
a1[i]= "g"+ a1[i];
}
}
}
for (var i = 0; i< a2.length; i++)
{
for (var j = 0; j< b2.length; j++)
{
if (a2[i] == b2[j]) {
a2[i]= "g"+ a2[i];
}
}
}
// john
document.write("<font color = '#FFFFFF'>" + "<b>" + "John    " + "</b>");
for (var i = 0; i< a1.length; i++)
{
if (a1[i].substr(0,1) == "g")
{
a1[i] = a1[i].substr(1,20);
document.write("<font color = '#00FF00'>", a1[i] + "    ");
}
else
{
document.write("<font color = '#FF0000'>", a1[i] + "    ");
}
}
// Michael
document.write("<br><br>");
document.write("<font color = '#FFFFFF'>" + "<b>" + "Michael    " + "</b>");
for (var i = 0; i< a2.length; i++)
{
if (a2[i].substr(0,1) == "g")
{
a2[i] = a2[i].substr(1,20);
// The Draw
document.write("<font color = '#00FF00'>", a2[i] + "    ");
}
else
{
document.write("<font color = '#FF0000'>", a2[i] + "    ");
}
}
document.write("<br><br>");
document.write("<br><br>");
document.write("<font color = '#FFFFFF'>" + "<b>" + "Draw day 1 " + "</b>");
document.write("<br>");
document.write("<font color = '#FFFFFF'>" + "<b>" + "Sat 08-08-2009 " + "</b>");
document.write("<br><br>");
for (var j = 0; j< b1.length; j++)
{
document.write("<font color = '#FFFFFF'>", b1[j] + "    ");
}
document.write("<br><br>");
document.write("<br><br>");
document.write("<font color = '#FFFFFF'>" + "<b>" + "Draw day 2 " + "</b>");
document.write("<br>");
document.write("<font color = '#FFFFFF'>" + "<b>" + "Sat 15-08-2009 " + "</b>");
document.write("<br><br>");
for (var j = 0; j< b2.length; j++)
{
document.write("<font color = '#FFFFFF'>", b2[j] + "    ");
}
</script>