Advertisement

12.15.2004 at 09:04AM PST, ID: 21243591
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Wrap text in Table cell
Tags: wrap, text, table, cell
Hi,

I have a table where the data in a particular cell to be wrapped at 15th character.

I tried the option of <td width=15 > but it won't work.

I need the text to wrapped at every 15th character.
 The  text contains spaces.

 For example : The text  in the Tabel cell is like this
" PO box No 345677 Reference information".
 
I need the above text to be wrapped like this.
PO BoX No 34567
7 Reference Inf
mation
 The Text comes from a database.(TD is databound)


I'm looking for any javascript .

Any help would be greatly appreciated.

Thanks
Anita
Start your free trial to view this solution
Question Stats
Zone: Web Development
Question Asked By: AnithaB
Solution Provided By: COBOLdinosaur
Participating Experts: 2
Solution Grade: A
Views: 814
Translate:
Loading Advertisement...
12.15.2004 at 09:42AM PST, ID: 12832519

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.15.2004 at 09:59AM PST, ID: 12832708

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.15.2004 at 10:18AM PST, ID: 12832897

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.15.2004 at 11:24AM PST, ID: 12833537

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.15.2004 at 11:59AM PST, ID: 12833887

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.15.2004 at 01:57PM PST, ID: 12834993

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.15.2004 at 03:00PM PST, ID: 12835613

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.16.2004 at 10:07AM PST, ID: 12843441

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
12.15.2004 at 09:42AM PST, ID: 12832519
you can use CSS

<td><div style="width:10pt; word-wrap: break-word;"> asldkjf alsdk jfalskasdf asdf asldfja a</div></td>


If you can use serverside
this should work for you

http://www.php.net/wordwrap
 
12.15.2004 at 09:59AM PST, ID: 12832708

Rank: Guru

<script type="text/javascript">
function formatStr(EL)
{
   strbuff=EL.innerHTML;
   newstr='';
   startI = 0;
   subsarr=new Array(strbuff.length/7+1);
   for (i=0;i<subarr.length;i++)
   {
      subarr[i]=strbuff.substr(startI,7);
      startI+=7;
   }
   for (i=0;i<subarr.length-1;i++)
   {
      newstr+=subarr[i]+'<br />';
   }
   str+=subarr[subarr.length-1];
   EL.innerHTML=str;
}
</script>
   

Cd&
 
12.15.2004 at 10:18AM PST, ID: 12832897
Hi Cd&

Can you please explain your script with comments

Thanks
Anita
 
12.15.2004 at 11:24AM PST, ID: 12833537

Rank: Guru

<script type="text/javascript">
function formatStr(EL)
// the EL is the target element passed fron the invokin process in the form:
// document.getElementById('idofelement');
{
   strbuff=EL.innerHTML;
// takes the content of the eleemtn and puts it into a string
   newstr='';
   startI = 0;
   subsarr=new Array(strbuff.length/15+1
// creates an array with a length that will hold all 15 character segments + the final bit.
// in the earlier versio I was using 7 which is incorrect 15 is the required size
   for (i=0;i<subarr.length;i++)
   {
      // this loop creates 15 character substrings an put them in anarray
      subarr[i]=strbuff.substr(startI,15);
      startI+=15;
   }
   for (i=0;i<subarr.length-1;i++)
   {
      // this loop creates a new string by concatenating the elements in the array
      // with an HTML line break tag between each segment
      newstr+=subarr[i]+'<br />';
   }
   str+=subarr[subarr.length-1];
     // the final segement is append outside to loop to avoid an extra linefeed
   EL.innerHTML=newstr;
    // the content of the target element is replaced with the new string
}
</script>
   

Generally something like this would be called from the onload even of the body tag:

<body onload="formatStr(document.getElementById('thecell'))">

Where the cell is tagged like: <td id="thecell">content</td>

Cd&
Accepted Solution
 
12.15.2004 at 11:59AM PST, ID: 12833887
Hi Cd&,
 
Thank You vey much. It's wroking great. I need to do couple of changes in your script.

subsarr=new Array(strbuff.length/15+1) // replaced by
subarr=new Array(parseInt(strbuff.length/15+1))

// because strbuff.length/15+1 results in a floating value and array must have finite integer value. // subsarr replaced by subarr

newstr='';
 startI = 0;
str=''; // declare variable for str otherwise compile error.

 I also modified the above script to make it general

formatStr(EL,maxchars)
maxchars is the no of characters per line or the nth character at which wrapping to be done. Here is the same script

function formatStr(EL,maxchars)
// the EL is the target element passed fron the invokin process in the form:
// maxchars is no of characters per line or the nth character at which text to be wrapped. For Ex At 15th character//
// document.getElementById('idofelement');
{
   strbuff=EL.innerHTML;
// takes the content of the eleemtn and puts it into a string
   newstr='';
   startI = 0;
   max=maxchars;
   str='';
   subarr=new Array(parseInt(strbuff.length/max+1));
// creates an array with a length that will hold all max character segments + the final bit.
// in the earlier versio I was using 7 which is incorrect 15 is the required size
   for (i=0;i<subarr.length;i++)
   {
      // this loop creates max character substrings an put them in anarray
      subarr[i]=strbuff.substr(startI,max);
      startI+=max;
   }
   for (i=0;i<subarr.length-1;i++)
   {
      // this loop creates a new string by concatenating the elements in the array
      // with an HTML line break tag between each segment
      newstr+=subarr[i]+'<br />';
   }
   str+=subarr[subarr.length-1];
     // the final segement is append outside to loop to avoid an extra linefeed
   EL.innerHTML=newstr;
    // the content of the target element is replaced with the new string
}

<body id="body" onload="formatStr(document.getElementById('tdRef1'),15)">
      
    <form id="Form1" method="post" runat="server">
<table border=2>
<tr><td id="tdRef1">Refer for other application and contain
</td></tr>
</table>

     </form>
      
  </body>
</HTML>


Thanks again . I accept your answer. Please let me know how to assig points to you.

Anita



 
12.15.2004 at 01:57PM PST, ID: 12834993
Hi Cd&,

in continuation to the above I have another question . How to implement the same functionality for a repeater control.

 In my web page I'm using a repeater to display data which consists of table and text in some of the cells to be wrapped

Thanks
Anitha
 
12.15.2004 at 03:00PM PST, ID: 12835613

Rank: Guru

Just call the function from the event that fires the repeater event handler.

to assign points just click the accept button next to the comment you want to make the answer, and it will bring up the grading screen.

Cd&
 
12.16.2004 at 10:07AM PST, ID: 12843441

Rank: Guru

Glad we could help.   Thanks for the A. :^)

Cd&
 
 
20080236-EE-VQP-29