Results 1 to 8 of 8

Thread: javascript cell background image

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    74

    javascript cell background image

    Hi Everyone,

    I'm very, very new to javascript, but I want to access a cell's background image to change it dynamically. I believe it has something to do with the style property, but I cannot seem to find it. If anyone could help me, I'd appreciate it.

    By the by, I'm trying to access the property through this manner:

    document.getElementsByName("TestCell")[0].style

    I can change the background COLOR, but not an image that is placed there. Kind of odd and I know it's possible, but I don't know it.

    Thank you if anyone can help me.

  2. #2
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    Code:
    document.getElementById('TestCell).style.background = '#ff0000';
    or you can use getElementByName ... i just always use Id for some reason (i put both in my element though to be safe).
    Hope that helps
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    74
    I know how to change the color, not a background image. How do you change a background image for a cell???

  4. #4
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    lol... guess i need to learn how to read.
    Code:
    document.getElementById('TestCell).style.backgroundImage = 'url(img/img.gif)';
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    74
    Thank you, I appreciate it greatly. I should have figured it would have been that.

  6. #6
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    Not a problem.
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  7. #7
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    By the way Mike, don't know if you know this already, but it's good that you use ID as NAME is gone in XHTML for most elements.

  8. #8
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    Originally posted by Rick Bull
    By the way Mike, don't know if you know this already, but it's good that you use ID as NAME is gone in XHTML for most elements.
    I knew there was some reason
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

Posting Permissions

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



Click Here to Expand Forum to Full Width