Solved

Clickable table cells.

Posted on 2010-08-28
7
437 Views
Last Modified: 2012-05-10
Hello,

I have a 2x3 table as follows:

#E#
ECE

Where # is an image (of set size), E is an empty cell other than a background colour and C is the contents of the cell. What I want to do is make each cell clickable without using javascript, how can I do this or achieve a similar effect - if need be replacing the whole table with something completely different with the same effect?

Thanks,
Uni

Note: Will be AFK for a few hours.
0
Comment
Question by:Unimatrix_001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33551339
You can put a transparent GIF in the empty cells and make that the link.  Usually 'border="0"'.
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 33551357
Hm, I see what you mean, although what do you recommend I do for the contents cell. See the contents cell will most likely have text and I don't really want just the text to be hyperlinked but all the space surrounding the text also?

Thanks,
Uni
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33551536
A javascript 'onclick' is the only way I know to make the whole <td> clickable.  You can't put an anchor around a <td>.  Demo code below.  The javascript method has two flaws.  #1 is that it is not recognized as a link because it's not an 'anchor' so your mouse cursor doesn't change.  #2 is that the method replaces the current window and 'back' doesn't work.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" summary="">
<tr><td onclick="window.location.replace('http://www.w3schools.com');">dibsplace</td><a href="http://www.w3schools.com"><td>&nbsp;Noplace</td></a></tr>
</table>
</body>
</html>

Open in new window

0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 3

Author Comment

by:Unimatrix_001
ID: 33552749
Hi Dave,

Thanks for that - is there a way to perhaps replace the table completely with something that could work?

Uni
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 33553836
The only element that is a clickable link is an anchor, just a standard link like <a href="http://www.yourwebsite.com">abc</a>.  You can replace the 'abc' with an image to make an image clickable but I don't know what else you can put there.  If you make your boxes out of divs, you would have to use javascript like with the <td>s in my example.
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 33554227
Hm, the limitations of HTML are REALLY showing up, how on earth did simple things like this never get into the standard early on is beyond me... Images it is then...

Thanks anyways,
Uni
0
 
LVL 3

Author Closing Comment

by:Unimatrix_001
ID: 33554230
:)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question