Solved

Clickable table cells.

Posted on 2010-08-28
7
430 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
  • 4
  • 3
7 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 3

Author Comment

by:Unimatrix_001
Comment Utility
Hi Dave,

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

Uni
0
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
:)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now