Results 1 to 2 of 2

Thread: Javascript game, syntax problem

  1. #1
    Join Date
    Nov 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascript game, syntax problem

    This is where i am currently at.

    http://www.darkelite.co.uk/allan/Con...04/connect.htm

    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.

    thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    FYI - onclick is not an element. It is an event. Try (for example):

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

    HTML Code:
    <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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •