Ok, so, this is my first post, if there is any info i am leaving out please tell me
this is the function:
this is how i made the images:
and heres the namer function:
now, what it does is create a 55x27 matrix of squares, when you mouseOver each square the idea is that it will change to the next color, I am passing the name of the image along to the mouseOver function. When I mouse over the image my alert(c) is telling me, correctly, the name of the square (i.e. r10c7) but the src of the image it tells me is unidentified when I modify the alert to alert(c.src). What I am thinking is that it is passing the name of the image to mouseOver as a string, but i'm not sure why this is a problem because I thought thats what the names of images always were. Any help would be greatly appreciated.
I know c++ reasonably well, but not javascript, I think I may be missing something as far as var goes i'm used to int double string and whatnot, also I have attached the full source if that is helpful
this is the function:
Code:
function mouseOver(c)
{
alert(c); <!-- just for debugging-->
if (c.src == "red.jpg")
{
document.c.src = "black.jpg";
}
else if (c.src == "black.jpg")
{
document.c.src = "yellow.jpg";
}
else if (c.src == "yellow.jpg")
{
document.c.src = "red.jpg";
}
}
Code:
for (i = 0; i <= 27; i++)
{
for (j = 0; j <= 55 ; j++)
{
document.write('<a href = "redbluegreen.html"> <img src ="red.jpg" border = "0" width = "20" height = "20" name = p onmouseover = "mouseOver(name)"> </a>');
document.p.name = namer(i,j);
}
document.write('<br />');
}
Code:
function namer(i, j)
{
return "r" + i + "c" + j;
}
I know c++ reasonably well, but not javascript, I think I may be missing something as far as var goes i'm used to int double string and whatnot, also I have attached the full source if that is helpful
Comment