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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.