Break string length when it has reached the max.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sadaiyan
    New Member
    • Jun 2008
    • 5

    Break string length when it has reached the max.

    I have a ASP page that displays text and when somebody does this zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzzzzzzzzz zzzzzzzz it breaks the page. How to restrict this and how to break this single line as multiple line display that as like a paragraph.Can anyone help me...... Thanks.
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Are you saying it breaks the visual formatting of the page?

    I'm not sure how you would code it in JScript, but in VBScript, it would be something like this:
    [code=asp]do until longString = ""
    if len(longString) < 101 then
    response.write longString
    longString = ""
    else
    leftside = left(longString , 100)
    if instr(leftside, " ") = 0 then
    response.write leftside & " "
    longString = right(longStrin g, len(longString)-100)
    else
    response.write left(longString , instr(longStrin g, " ")) & " "
    longString = right(longStrin g, len(longString)-instr(longStrin g, " "))
    end if
    end if
    loop[/code]I hope the conversion to jscript isn't too hard, let me know if this helps.

    Jared

    Comment

    Working...