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

forcing a new line with a text box 2

Status
Not open for further replies.

nk9100

Technical User
May 13, 2005
67
GB
Hi, I am creating a survey site, and once the participant has entered the text in a text box, they can then go to the main menu to 'view your entry', which I want to be a printer friendly version of what they have entered, the problem is, is that when the text is selected from the db, it is displayed in one long continuous line, rather than in a 'paragraph' format, is there any way i can overcome this?

Life is a journey that always ends up in the place
 
I do not have access to the code at the moment but I did something similar to this myself.

If I remember correctly what I had to do was process the text before submitting to the database and change the carriage return line feeds to text strings and then when reading them back look for those strings and turn them back to real CR LFs.

In my case I had a web form they typed information into.
I wanted to maintain the exact formatting that it had in the text box. I had to determine the number of characters displayed per row of the text box and then loop through it. Wherever I found a carriage return line feed before the end of the line I would replace it and at the end of each row of text insert another set. This way if their text just wrapped I would be inserting the CRLF to keep tha formatting and if they hit CR during typing I would be detecting and preserving that as well.

It all depends on how you want to display the info though.
You could pick a max length to display per line and parse that text string out inserting CRLF every x characters.

Remember though if your box size is not fixed (stretches with the page) or different fonts are used then the number of characters that would display per line can vary.
 
Hi, thanks alot!, If I use

Code:
<textbox readonly="true" value="<%= rsCheckUser("participatein_gh")%>" />

That should at least stop them trying to edit it? Just for display sake thats all.

Life is a journey that always ends up in the same place
 
you can also do this to disable from being edited...

<textbox [red]DISABLED[/red] value="<%= rsCheckUser("participatein_gh")%>" />

-DNG
 
Does UNSELECTABLE work with a textbox field?
Any advantages/disadvantages?
 
Textboxes use linefeed characters to indicate a new line, however to get them displayed in HTML you must use a break tag. This easy to do however, just append the VbCrLf with a <br>:

<%=replace(rsCheckUser("participatein_gh"),vbCrLf,"<br>"&vbCrLf)%>

The text should be displayed as you wanted it without having to use a texbox field!



Compromise: Where I don't get what I want, but I'm happy because you didn't either.
 
Does UNSELECTABLE work with a textbox field?

I dont think so. Its for <div>, <span>, <body> tags...

correct me if i am wrong...

-DNG
 
Hi,

I couldnt get UNSELECTABLE to work, it allowed it to be edited etc, so stick with readonly I think.

Life is a journey that always ends up in the same place
 
I use UNSELECTABLE in an Input tag and it keeps the focus from ever going to that field even if they click on it, not to mention being able to highligh anything within the field.

I am using IE5.5+ though, it may work differently it other browsers.
 
Instead of using both vbCrLf and <br> you can just replace the vbCrLf with <br> when you need to display it without using a text box.
[tt]
strText = replace(strText, vbCrLf, "<br>")
[/tt]
That will keep things from looking strange when you DO want them to edit it.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I know that only the <br> is necessary to make it display correctly in the web browser, but I like to keep the vbCrLf in there so that if you view the source code when your troubleshooting everything is on a new line there as well. I would only use the replace function at the time of display. I wouldn't change the information in the database, so it really shouldn't make any difference when it comes to editing it.


Compromise: Where I don't get what I want, but I'm happy because you didn't either.
 
Am I supposed to enter the vbCrLf somewhere? I am totally unfamiliar with this

Life is a journey that always ends up in the same place
 
vbCrLf is a MS constant which contains a carriage return and a line feed.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
works a treat.

Thanks alot again

Life is a journey that always ends up in the same place
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top