Jump to content

Making a table Cell -or- Row an Anchor


lead2gold

Recommended Posts

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

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

Link to comment
https://forums.phpfreaks.com/topic/11505-making-a-table-cell-or-row-an-anchor/
Share on other sites

Your table cells need to look something like:

[code]

<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>
[/code]

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.
you can use an onclick event, like this
[code]
<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>
[/code]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.