Jump to content

Archived

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

lead2gold

Making a table Cell -or- Row an Anchor

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.