#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    9
    Rep Power
    0

    Limiting Characters with COLD FUSION




    I was wondering if it was possible to set a character limit for a select box with Cold fusion. The effect I'm trying to achieve is by limiting the character limit to 27. If the word(s) is longer, the extra characters should be cropped and replaced by ... making the limit really at "30"? Could CFM do somehting like that or do I have to use JAVASCRIPT?
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    You can do this with CF on the server side very easily, something like:

    <cfif len( trim( form.myFormField ) ) gt 30>
    <cfset form.myFormField = left( trim( form.myFormField ), 27 ) & "...">
    </cfif>
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    9
    Rep Power
    0
    Thanks for replying! I'm gonna try that as soon as it calms down here today.

    I can't wait to get up to speed with CFM, the code seems so straightforward and clean.

    Cheers.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    7
    Rep Power
    0

    Question Limited output with an insert


    Can I do this with a simple 'insert' record field?

    I have a product description and would like to limit the size to 30 characters and have a link with a trailing '...' for folks to click for the full description.

    Thanks...you guys rock!
    -she
  8. #5
  9. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,172
    Rep Power
    4274
    yes, eshera, you can, see post #2
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo