File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Breaking a word in a TD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Breaking a word in a TD" Watch "Breaking a word in a TD" New topic

Breaking a word in a TD

Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
Hi All,
I am having problem in displaying a text in a TD in table. My req. goes like this. I have a discussion form, in which a person can post a comment. The comment is displayed as a single line link in the view page. For eg. if a person gives a comment for 2000 chars. I would be showing what ever it can accomodate in a particular TD. My TD width is 25%. When a particular line exceeds this 25%, the remaining characters are stripped off. When a person replies to this comment, a few sapces are given infront and displayed as separte row below this. Now also it should be displayed as single line link but the effecrtive width is reduced.And it goes like this.

I want to know is there a any way to strip of the charactes to width of particular TD in a table.

Thanks in Advance.

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You can try using overflow="hidden" on the cell, but do not think that will work with percentages. Why don't you just cut the lenght to a cerain size on the server?

Arulanand Dayalan
Ranch Hand

Joined: Aug 10, 2005
Posts: 124
Thanks a lot Eric for Quick reply.
I tried out even with Px, it did not work out.

Please find the code below.

<TD COLSPAN="1" CLASS="ACTS_Fld_Vl" ALIGN="left" style='width:500px;overflow:hidden ;'>
<%if (objCommentsDTO.getStrDisplaySubject() != null && objCommentsDTO.getStrDisplaySubject().equalsIgnoreCase("No Comment")) {%>
<IMG src="images/news_unselected.gif" width="12" height="16"> <B><%=strValue%></B>
<%} else {%>
<IMG src="images/news_unselected.gif" width="12" height="16">
<A href="javascript:funComment('<%=objCommentsDTO.getSeqID()%>',
<%=ComentsUtil.parseContent(strValue)%> </A>

We dont know how many character can be accomodated in a particular TD. So that we can calculate number of character at server level. If you could provide us any suggestion it could be of great help.

I agree. Here's the link:
subject: Breaking a word in a TD
It's not a secret anymore!