Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - limiting characters
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

limiting characters

 Post Reply Post Reply
Author
ainsworth14 View Drop Down
Groupie
Groupie


Joined: 05 August 2003
Location: United Kingdom
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote ainsworth14 Quote  Post ReplyReply Direct Link To This Post Topic: limiting characters
    Posted: 15 August 2004 at 11:28am

hi there,

just curious to know if there is a way to display only a specific amount of characters in a description field on an asp page?

for example i have a description field in my DB but when displayed on my asp page i only want say 50 characters displayed (kinda like a brief description, but without having to create a new DB field for it).

i new to the development side and was just curious?

 

many thanks

mark

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2004 at 11:30am

Reponse.Write Left(Variable, 0, 50)

Left(string, startat, length)

Back to Top
ainsworth14 View Drop Down
Groupie
Groupie


Joined: 05 August 2003
Location: United Kingdom
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote ainsworth14 Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2004 at 11:54am

thanks for swift response

where would i place in this string?

<%=(rsResults.Fields.Item("Description").Value)%>

 

i have tried a few times but get errors?

thanks
mark

Back to Top
ainsworth14 View Drop Down
Groupie
Groupie


Joined: 05 August 2003
Location: United Kingdom
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote ainsworth14 Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2004 at 12:03pm

even better would be a word count, so not to cut off words half way through, is this possible?

 

 

Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 15 August 2004 at 1:10pm

paste <%= Left(rsResults.Fields.Item("Description").Value),0,50) %>

where you want it displayied, after the connection is opened.

 

to stop at x words you could try the following

strDescTemp = rsResults.Fields.Item("Description").Value

saryDESC = split(strDescTemp," ")

intCounter = 1

do WHILE intCounter < Number of words

if not intCounter = 1 then strDesc = strDesc & "&nbsp;"
strDesc = strDesc & saryDESC(intCounter)

intCounter = intCounter +1

loop

you can try teh above code, please note that it hasn't been tested. if you get any errors please feel free to reply back.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.