Using Javascript to trim some text to length


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Using Javascript to trim some text to length

  1. #1
    Burt Abreu Guest

    Using Javascript to trim some text to length

    Hi,

    I'm wondering if someone can help me with a bit of javascript. The
    intelligent half of our team is off on other jobs (and you guessed right if
    you figure I'm not that half) and I thought I might be able to get some help
    here and make this small change myself. If you go to
    http://www.vbexplorer.com/ you'll see at the bottom of the page the 'Newest
    User Submissions' box. I don't like the fact that the long lines wrap and
    was wondering if I can just insert a bit of script that will snip the lines
    to a certain length. In a total pseudo and clueless example here is
    basically what I;d like

    If the category column can hold say 17 characters without wrapping I'd like
    to have a small script to take something like this

    Files, Folders And Directories

    and turn it into this

    Files, Folders...

    I know I could just rename everything but that isn't practical since the
    title, name and category are used in other places where the length is not a
    problem so I don't want to end up with illegible coded names to fit
    everything in. (I guess I can steal a page from Outlook and put the text in
    a 'Title=category name' so they can get the full name on mouseover -at least
    in IE)

    The values I need to 'chop' are ##title, ##Name, and ##CategoryName which
    are inserted from the database. Here's the pertinent code.

    <TD><a href="show.asp?id=99&itemid=##id;">##title;</a></TD>
    <TD width="100"> <a
    href=show.asp?id=98&authorid=##submitterid;>##Name;</a></TD>
    <TD width="120"> <a
    href=show.asp?id=97&categoryid=##CategoryID;>##CategoryName;</a></TD>

    If there is some simple way of doing this (more pseudo stuff) ala

    <a href="show.asp?id=99&itemid=##id;"><script>chop (17,
    ##title</script></a>

    that'd be great.

    Thanks a lot,

    Burt Abreu
    vbexplorer.com





  2. #2
    Burt Abreu Guest

    Re: Using Javascript to trim some text to length

    Fixed it, no need to respond -assuming you were going to.





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center