Hi.
I'm creating a simple memory game in which the user has to make pairs
from cards. I would like the user to see the variable "trys" (the
score) update on the page dynamically (in a text box would be great).
I can do this by showing a msgbox every time try increments but this
is annoying to use. I have been trying for hours to get this to work,
using innerhtml.
function turnOver(e)
{
if (matchCount<8 & !matched[e.name]) //If the game hasn't finished
and the chosen card isn't already matched then...
{
if (clicked<1) //If this is the first card
{
firstCard=e; //grab first card object
pair=cards[firstCard.name]; //get first pair number from cards
array
e.src=document.images["load"+pair].src; //flip over first card
}
else //If one card is already chosen
{
e.src=document.images["load"+cards[e.name]].src; //flip over second
card
if (pair!==cards[e.name]) //If cards aren't the same then...
{
trys++ //UPDATE THE SCORE ON THE PAGE HERE
alert("No Match! " + trys + " trys so far")
firstCard.src=document.images["load0"].src; //flip first card back
e.src=document.images["load0"].src; //flip second card back
}
else //If cards are the same then...
{
//Record matched cards and increase matchCount
matched[firstCard.name]=true;
matched[e.name]=true;
matchCount++;
trys++ //UPDATE THE SCORE ON THE PAGE HERE
}
}
Any help would be greatly appreciated.
Mike