Clickable TR

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
SheDesigns
Forum Commoner
Posts: 42
Joined: Tue Nov 18, 2008 9:51 am
Location: Buffalo, NY

Clickable TR

Post by SheDesigns »

:oops:

I have a list of database records that display in a table format. I don't want them to have to click the individual link. I'd like the entire table row to be a link. How can I do this?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Clickable TR

Post by pickle »

You can't make it a link per se, but you should be able to attach a click listener to it. There may be some issues with bubbling - ie: if the user clicks on a cell in that row, does the click event continue to travel up the DOM. If you're using a library (jQuery, Prototype, MooTools), I'd imagine the library would take care of that stuff.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Clickable TR

Post by jayshields »

pickle wrote:You can't make it a link per se, but you should be able to attach a click listener to it. There may be some issues with bubbling - ie: if the user clicks on a cell in that row, does the click event continue to travel up the DOM. If you're using a library (jQuery, Prototype, MooTools), I'd imagine the library would take care of that stuff.
I've never had problems with things travelling up the DOM. Do you mean using something like this?

Code: Select all

<tr onclick="window.location('whatever.php');"><td>blah</td></tr>
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Clickable TR

Post by pickle »

Ya - that's what I was referring to.

Didn't want to just give her the code though ;)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply