Forum Moderators: coopster

Message Too Old, No Replies

table rows - cant copy text

         

bilenkyj

11:06 am on Mar 31, 2008 (gmt 0)

10+ Year Member



i have a table that is created based on the contents of a database, it reads all the rows in the db table and while there are rows to be read lists them on the page and builds the table. The problem is that i can see to be able to click in the text in the generated table to copy the test

the table rows are hyperlinks which i think is the main issue, but typically with hyperlinks you can drag mouse cursor over the text and copy with ctrl+c

the scripts builds the table rows like this -

echo"<a href=\"viewconnectors.php?company_name=".urlencode($myrow['company_name'])."&filter_by=".urlencode($_POST['filter_by'])."\"><tr style=\"cursor:hand\" bgcolor=\"#F0F0F0\" onMouseOver=\"this.bgColor = 'white'\" onMouseOut =\"this.bgColor = '#F0F0F0'\" >";

Is there another way i can make the table rows as hyperlinks but have the ability to copy the text

deMorte

12:41 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



It could be that I didn't really understand the question, so I could be way off with my explanations.

Usually one uses links like following:


<a href="http://www.example.com">Example.com Website</a>

On this you can copy the text "Example.com Website" by painting the text. I think you can only copy the url ("http://www.example.com") by right-clicking the link and selecting the copy option from the menu.
So one option could be to print the url in an cell.

if this did not help, maybe you could illustrate the problem a bit more.

penders

2:07 pm on Mar 31, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



echo"<a href=\"viewconnectors.php?company_name=" . urlencode($myrow['company_name']) . "&filter_by=" . urlencode($_POST['filter_by']) . "\"><tr style=\"cursor:hand\" bgcolor=\"#F0F0F0\" onMouseOver=\"this.bgColor = 'white'\" onMouseOut =\"this.bgColor = '#F0F0F0'\" >";

It doesn't look as if you are outputting valid HTML. The anchor (inline element) cannot contain <tr> (block-level) elements. Your anchor needs to be inside your <td> elements. If the HTML is not valid then browser behaviour is going to be unpredictable. Your ampersands (query string separator) also need to be encoded as &amp; to validate.

bilenkyj

2:39 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



the page is layed out like this

<hyperlink><tr>
<td>
<td>
<td>
<td>
<td>
</tr></hyperlink>

It works, the whole table row is a hyperlink, i need to tell the cursor to be a hand when i hover over it but the link works, the question is why will it not allow me to copy the contents of the row or even highlight it, it seems treat the row almost like an image

bilenkyj

2:45 pm on Mar 31, 2008 (gmt 0)

10+ Year Member



[webmasterworld.com...]

found similar

penders

7:58 am on Apr 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It works, the whole table row is a hyperlink, i need to tell the cursor to be a hand when i hover over it but the link works, the question is why will it not allow me to copy the contents of the row or even highlight it, it seems treat the row almost like an image

I think you need to test it a bit more. 'It works' in IE6/7 so much as the href is followed, but as you have found you can't select the text, nor does it visually behave like an anchor. It does not work at all in Firefox, Opera or Safari. Probably because it is not valid HTML and this is also stated in the thread above.

An HTML issue really... I don't think you can reasonably start to figure out why something isn't working when the HTML itself is invalid. Step 1 - valid HTML. (W3C HTML Validator [validator.w3.org])

(IE sometimes prevents the selection of text when certain elements have been left open. The <base> element is a common problem in this respect.)

You may want to assign an onclick event to the <tr> element instead. You can keep an anchor (for SEO and non-JavaScript users?), but this will need to go inside a <td>. You could use JS to automatically assign the onclick event based on the anchor inside the row?

NB:

cursor:hand
is again IE only. You need to use
cursor:pointer
for cross-browser compatibility. Also bgcolor is a deprecated attribute, so you may want to consider using CSS
background-color
instead.