Click to See Complete Forum and Search --> : A quick trim please


rjoseph
09-29-2007, 03:04 AM
Hi guys

I have a simple one for you.

I am currently using the following script to display data from my database field onto my page

-------------------------
<a href="http://www.mysite.com/<%=oRsB.fields("customername")%>.asp"><%=oRsB.fields("customername")%></a>
-------------------------

However, the "customername" field in my database sometimes contains data with many character spaces at the end eg:
"Mr Ray Harding "

I think you know what's coming next, I need to display the customer's name without the white spaces at the end (trim function?)but also replace any spaces in the middle with a "-". Thus, the data will be displayed as:
"Mr-Ray-Harding" and my hyperlink will direct to: "http://www.mysite.com/Mr-Ray-Harding.asp" without the white spaces.

How is this done?

Any help would be fully appreciated

Best regards

Rod from the UK

gil davis
10-01-2007, 08:31 AM
Do the Trim first to delete the padding spaces, then use Replace(thestring, " ", "-").

rjoseph
10-02-2007, 01:40 AM
Thanks