Jump to content


Photo

Making a table Cell -or- Row an Anchor


  • Please log in to reply
2 replies to this topic

#1 lead2gold

lead2gold
  • Members
  • PipPipPip
  • Advanced Member
  • 164 posts
  • LocationOttawa, On

Posted 08 June 2006 - 05:34 PM

With respect to this example:
<table class="tablestyle">
<tr class="rowA"><td class="cellA">Link</td></tr>
<tr class="rowB"><td class="cellB">Link</td></tr>
</table>

Is it possible to make... say rowB a link to "/somepage.php" reguardless of where they clicked on the row?
Is it also possible to make ... say cellA a link to "/anotherpage.php" reguardless of where they clicked in the cell?

Is this something you need JavaScript for?

If you visit my website [a href=\"http://hitech.lead2gold.org\" target=\"_blank\"]here[/a] you can see that the calendar works the same as everyone elses PHP calendar... but i wanted to make it so the entire cell became a link instead of just the anchor within.

Chris



#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 08 June 2006 - 05:57 PM

Your table cells need to look something like:


<td class="cellA"><a href="/anotherpage.php" style="width:XXX;display:block;">Link</a></td>
<td class="cellB"><a href="/somepage.php" style="width:XXX;display:block;">Link</a></td>

where XXX is the width of the cell you want in pixels, you need to make all the anchors the same width in that table, they should all then fill the cells so moving the mouse anywhere in the cell highlights the link.

Actually I'm not sure if you need the display:block there, try it with and without.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 08 June 2006 - 09:05 PM

you can use an onclick event, like this
<table class="tablestyle">
<tr class="rowA" onclick="location.href='some_page.php';"  style="cursor:pointer;"><td class="cellA">Link</td></tr>
<tr class="rowB" onclick="location.href='some_page.php';"  style="cursor:pointer;"><td class="cellB">Link</td></tr>
</table>

The style style="cursor:pointer;" will make the mouse change to a finger so it looks clickable.

NoGray.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users