Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Truncate output from SQL 2

Status
Not open for further replies.

Kozimoto

Technical User
Sep 25, 2002
44
US
Hello.

I have an ASP/Javascript results page with output from an nvarchar field in SQL. I need to truncate the output to a predetermined number of characters followed by (...). I found one post using:

<%=LEFT(SearchResults.Fields.Item("entry_content").Value).Value,100)%>

but I receive a 500 error using this code and assume this code works with Access and not SQL.

Any suggestions would be appreciated. Thanks in advance.
 
Hey Chris thanks for the reply. I was hoping for something a little more Dreamweaver code centric. Or an explanation as to why the code sample I picked up in another DW post worked for them and not for me.

I appreciate your ASP thread through. if all else fails I'll see what I can do with a little hand coding.
 
Thanks Cheech. Truncate-IT is ASP/VBscript only. I've also checked out Crop Sentence too.

Any other ideas?
 
That looks interesting Cheech. I'm not sure how I would code the DW string that returns the text from my nvarchar field into this code. My code looks just like the code in my first post in this thread.
 
Code:
<script>
var str = "<%=SearchResults.Fields.Item("entry_content").Value%>
document.write(str.substr(0,100))
</script>

or something like that

Cheech


[Peace][Pipe]
 
Hi Cheech. Thanks for all your efforts on this post. I've scoured the web looking for a solution. Truncate It works great, but I'm knee deep in setting up this site in Javascript. Your suggestions look like the best option so far, but I would also need the script to not cut off in the middle of a word followed by (...read more) I'll keep looking.
 
Can't resist this, but wouldn't spending about 5 mins learning how to use
Code:
var str = "<%=GetSnippet(SearchResults.Fields.Item("entry_content").Value,100)%>
been simpler than 2 days of firing questions back and forth?



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top