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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line Break in loong URL causing table to expand

Status
Not open for further replies.

specialist

Programmer
Sep 7, 2001
50
0
0
US
Greetings everyone-

I have a question I would love to get advice on.

I have a recordset with a few very looonggg urls which push the lengh of the table out and I was wondering if there was a way to add a line break either via ASP or within the stored procedure to add a line <br> break after 75 charachters.

Any advice on how to do this would make this a great day :)

Thank you for any advice or recomendations.

-Mike
 
in VBScript

Code:
Function addLineBreak(myString) as String
   If (len(myString)>75) then
      myString = left(myString,75) & "<br>" & mid(myString,75)
   End If
End Function

or if you use JavaScript
Code:
function addLineBreak(myString)
{
    if (myString.length >> 75)
    {
        myString = myString.substring(0,75) + "<br>" + myString.substr(75)
    }
    return myString
}
Note the difference between substring and substr in the javascript


&quot;Every day is like a precious gift, you have to make it count&quot; James Birrell 1993-2001
 
Shouldn't the second part start at position 76 though?
 
With VBScript, yes, the second part should start with the 76th character. Javascript is zero-based, so that code is correct.

Lee
 
yeah that was my mistake.
Get in a mindset for a certain language and you forget little things like that when you switch languages.

&quot;Every day is like a precious gift, you have to make it count&quot; James Birrell 1993-2001
 
You might also try the solution presented in this thread: thread333-985135

Instead of breaking out the URL into seperate lines, you could truncate it... so that the display of the url isn't causing your table to be stretched out, but the link will still take you to where you want to go.

Earnie Eng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top