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

break up text string 1

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
Hi i have an iframe that display data from a database.

The problem is that if someone enters data into the db like this:
tttttttttttttttttttttttttttttttttttttttttttttt,ttttttttttttttttttttttttttttttttttttttttttttttttttt,ttttttttttttttttttttttttttttttttttttttttttttttttttttttt,tttttttttttttttttttttttt

OR

vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

the iframe overflows the set iframe width with the text cause there is no spaces. How could i format such data from the db to prevent the overflow. This is what i'm working with:
............
Conn.close: set Conn=nothing

response.write("<html><head></head><body style='overflow-x:hidden; overflow-y: auto'><table><tr><td width='315'>")

For lnRowCounter = 0 To Ubound(MyArray,2)
Response.Write MyArray(lnColumnCounter, lnRowCounter) & "<hr />"
Next

response.write("</td></tr></table></body></html>")

I have the font set to courier so that each letter and numer is the same distance much like this text area box that i'm typing this question into. 35 characters can fit nicley in the ifram box but any more should continue on the next line, I'm not sure how to do this? any thoughts on this. THanks
 
In ie, you can do this with word-wrap:break-word inline style.
[tt]
response.write("<html><head></head><body style='overflow-x:hidden; overflow-y: auto'><table><tr><td width='315' [blue]style='word-wrap:break-word;'[/blue]>")[/tt]

ref
In moz (ff/nn), it is not (yet?) supported. You can only, if the desire is so strong, insert <br /> at appropriate places of the string server-side.

I say "yet?" because paradoxically it is featured in css level3 working draft. So, for once (!?), ie is ahead; and for now, it is ie-proprietary. Maybe because the previous editor of the working draft was a ms person and had "subversively" put it there---just joking. In any case, moz over-zealous could not refute it outright, either.
 
Thanks tsuji, my quest is fixciated towards a xbrowser solution, i think that i need to handle formating at the server level, what about something like this:

strLength = Len(arrayValue)
arrString = Split(strLength, ",") ' hoping that there is a comma to split at if not they try a space
If arrString < 1 Then 'there is nothing to split at
arrString = Split(strLength, " ")
If arrString < 1 Then ' there is not spaces to split at
arrString = Split(strLength, Left(strLength,35)) ' iframe only allow 35 character across before it overflows

My thinking is that would it be possible to format the string to fit the iframe, I only need to worry about a "single word" being over 35 characters and if so continue it on the next line, any suggestions on how to properly accomplish this? Thanks
 
Ok this is what i have so far, i'm stuck at knowing how to determine the rest of the string after 35 characters, any suggestions?

I think it would go something like,
myArray = Split(txtString, " ")
For each x in myArray
If Len(myArray(x) > 35 Then
myArray(x) = Left(myArray(x), 35) & "<br />" &
'''''''rest of string after 35 character, how to do this??
End If
Next

am i going about this correctly?
 
For character strings, like this.
[tt]
'txtString be the raw data retrieved
dim txtString_wrapped : txtString_wrapped=""
for i=1 to len(txtString) step 35
txtString_wrapped = txtString_wrapped & mid(txtString,i,35)
if (i+35) < len(txtString) then
txtString_wrapped = txtString_wrapped & "<br />"
end if
next
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top