Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    New Zealand
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Click-able Table Cell

    Has anyone used or seen the code which makes a table cell clickable like a button or text link?

    There is pleanty of ways of changing the background colour of a cell which i am using but you still need to click the actual text link within the cell to activate the link. I would like to be able to click anywhere in the cell and have it follow the link (and do the pointing finger cursor anywhere on that cell too).

    If you can shed any light, it would be much appreciated.

    Thanks.

    -- candrias --
    eTheory - the theory of revolution

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This what you want?

    Code:
    <td style="background-color: red; cursor: hand;" onclick="location.replace('http://www.google.com');">My Cell</td>

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    New Zealand
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thats perfect goose, thanks.
    eTheory - the theory of revolution

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    Sacramento, California
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts
    U could use this to change cell color on onclick, onmouseover, or onmouseout:

    <td onclick="this.style.color='#000000'" onmouseover="this.style.color='#FFFFFF'"
    onmouseout="this.style.color='#CECECE'">SOME TABLE DATA</td>
    Hairynugs


    Simple is best.

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    New Zealand
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, i already had a piece of code like what you suggested which changed the class of the cell (which was defined in an external style sheet) but it was only changing the colour of the cell. Now it also changes the cursor and activates a link onClick.

    Thanks for the help from both of you, it's working well now.
    eTheory - the theory of revolution

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I doubt if all or even many browsers support events for a table cell...
    You could revert to using an image as link.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #7
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Originally posted by ronaldb66
    I doubt if all or even many browsers support events for a table cell...
    IE4+/NS6+/Opera 5+?

    really just leaves out NS4.

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    ...stop picking on Navigator...

    <html>
    <head>
    <title>untitled</title>
    </head>
    <body>
    <div align="center">
    <table width="200" border="1">
    <tr>
    <td width="100" height="50" bgcolor="green" onclick="alert('green')">
    <ilayer><layer width="100" height="50"
    onload="this.document.onclick=function(){alert('green')}">
    </layer></ilayer></td>
    <td width="100" bgcolor="red" onclick="alert('red')">
    <ilayer><layer width="100" height="50"
    onload="this.document.onclick=function(){alert('red')}">
    </layer></ilayer></td>
    </tr>
    </table>
    </div>
    </body>
    </html>


  •  

    Posting Permissions

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