jturkington
asked on
Displaying First N characters on Output
I have a table where i want to cfoutput query a number of fields from a database
I have a one field that can have quite a long description and would just like to display the first 100 characters and then cut it off with a couple of ..
Example
FieldID Description Field3
1 a long description lots of text... etc..
How would i go about accomplishing this ?!
Cheers
JT
I have a one field that can have quite a long description and would just like to display the first 100 characters and then cut it off with a couple of ..
Example
FieldID Description Field3
1 a long description lots of text... etc..
How would i go about accomplishing this ?!
Cheers
JT
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>All of these answers are correct, but consider this that simply using Left() will "chop" your words off in the middle of the word. I would recommend using a UDF:
the way we do it for our 'news' headlines is up to the first .
left(string,find(". ",string)) <<-- notice the space after the . , prevents cut off of $10.36, looks for the first full stop.
no problems as of yet
the way we do it for our 'news' headlines is up to the first .
left(string,find(". ",string)) <<-- notice the space after the . , prevents cut off of $10.36, looks for the first full stop.
no problems as of yet
Yeah, that works if you need to stop at a full sentence or need to avoid chopping dollar values -- definitely a plus in many situations. We use the FullLeft() in areas where we need a "blurb" that could potentially lead to a very long page. The common denominator is that either method prevents "chopping," which I personally can't stand! :-)
Also another thing to consider is that if your string is LESS than 100 you could get an error so be careful that whichever method you use accounts for the actual length of the string for shorter strings.
ASKER
How would you validate this with
<cfoutput>
#left(field,100)#<cfif len(field) GT 100> ...</cfif>
</cfoutput>
<cfoutput>
#left(field,100)#<cfif len(field) GT 100> ...</cfif>
</cfoutput>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
glad i could help
thanks for the points
thanks for the points
see here
http://www.blakems.com/archives/000077.html
this is a great site
http://www.blooberry.com/indexdot/css/properties/position/textoverflow.htm