FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

How to make a single line (nowrap text) in a table?

 


akoni176
how to display a single line (nowrap text) in a table.?
and how to make a hyperlink in a single row with 4 column.?

i have a long paragraph in a single cell, and by default a column wrap the paragraph to display all text.

i want to show only text that fit a size of the cell...

like some email system.. that the subject only display single line even it is a very long paragraph..



thanks in advance..

ps i dunno if this is a right forum...
Esch
If you simply want to make text not wrap, you can set the CSS property "white-space" to "nowrap".

Unfortunately, it seems like your problem is far more complicated than that, since you want to hide the rest of the text if it exceeds the size of your container. Assuming that the size of the cell in which the text is being displayed is constant, the easiest way to do this would be to check the length of the string server-side and truncate it if it was too long, perhaps adding "..." afterward to indicate additional content.

If the size of the container can change dynamically client-side, then you'll have to do some javascript wizardry to get it to dynamically truncate the text as well when it exceeds the size of its container. As a general idea, I'd place the text in a div, make its position relative (so it can exceed the size of its container), and then check its fully extended size against that of its container; if it's greater, just truncate the innerHTML property of the div until it's approximately the right size (of course, you'll have to assume a constant font size for this to work as well).

In any case, it's a bit of a tall order if it's client-side; my recommendation is just to make the cell a fixed width and do the truncation server-side. Also, I'm not entirely sure what your second question about the "hyperlink in a single row" meant; it may help if you rephrase it.

Hope that helps.
akoni176
thanks buddy,,,

about my 2nd question, i want to make a hyperlink the entire row, not only the text in a certain cell. this will happen when mouseover occur in a certain row of a table.

thanks in advance...:0
sb3700
Try making the code for your table:

Code:

<table>
  <tr onclick="location.href='url'" style="cursor:pointer">
    <td style="width:x;overflow:hidden;whitespace:nowrap">Long text goes here.....</td>
    <td>...</td>
    <td>...</td>
    <td>...</td>
  </tr>
</table>


It's not tested but it should work.
You can use classes for the td's and store the rules separately if it applies to more than one cell.
Make sure you set a value for the width and the URL (replace x and url with the appropriate values).

PS: You might want to add a status bar changer when you mouse over the link.

I think that is what you want...
akoni176
Try making the code for your table:

Code:

<table>
<tr onclick="location.href='url'" style="cursor:pointer">
<td style="width:x;overflow:hidden;whitespace:nowrap">Long text goes here.....</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
</table>



It's not tested but it should work.
You can use classes for the td's and store the rules separately if it applies to more than one cell.
Make sure you set a value for the width and the URL (replace x and url with the appropriate values).

PS: You might want to add a status bar changer when you mouse over the link.

I think that is what you want...



thanks a lot, but some error occurs , anyway, im trying to find a way this errors, thanks.. it helps me a lot...:0
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.