Solved

Clickable table cells.

Posted on 2010-08-28
7
431 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 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do i remove the outer scrollbar? 2 38
CSS measurement 10 34
Disabled form text field 2 22
compact pure CSS Read More Toggle 4 19
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…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
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…

930 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

11 Experts available now in Live!

Get 1:1 Help Now