View Full Version : Javascript game, syntax problem

12-06-2006, 12:05 PM
This is where i am currently at.


I am trying to assign the onlick element to the arrow image. When clicked, this causes the function to run which makes the desired cell to change to a red counter.

I think i am on the right lines, but it clearly doesn't work, so if someone could check my syntax or make a suggestion about changing something it would help me out big time.

...i've read about "documnent.getElementById(" ").src" and think this may help, however don't know how to implement this.


12-06-2006, 05:48 PM
FYI - onclick is not an element. It is an event. Try (for example):

<img src="arrow.gif" onclick="document.getElementById('pred').style.backgroundColor='red';">


<td id='pred'>Whatever's in here should be text and/or small images</td>

Notes: You said cell and that typically means a table cell (<td>), the above cell should be properly set in a table. Only one tag per page can have any given id.