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

textarea readonly problem

Status
Not open for further replies.

cuetzpalin

Programmer
Jun 5, 2002
99
US
Hello I have a textarea element that displays user comments on a read only page. However, if the user, in a previous "edit" screen, has placed text that exceeds my height on the "view" page it doesn't show when you print the page. Is there a way you can dynamically adjust the text box area when it's set height has been exceeded? Also the reason I'm using the textbox area is because it retains the carriage returns previously entered in the "edit" screen. I tried using a label and it doesn't recognize the carriage returns.

<TR>
<TD bgColor='white' ColSpan="7">
<font name="arial" color="black">Details</font>
<br>
<hr width=635>
<TEXTAREA style="WIDTH: 629px; HEIGHT: 548px" readonly='readonly' name=txtDetails rows=12 cols=68><%=Trim(StrDetailsOfProject)%><%=vbCrLf%></TEXTAREA>
</TD>
</TR>

Thank you!
 
You could use a div or paragraph, and replace the carriage returns with <br> before displaying it.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
You can also use a div or paragraph with the style attribute "white-space: pre;". I think that this is now preferrable to the <pre> tag.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
While I have never heard that there is anything wrong with the pre tag, I guess you could use that solution. However, running this code:
Code:
<pre>
This text   has spaces     and 
 many many 
many oh so   
many
line breaks !!!     yeah
quit
</pre>

<div style="white-space: pre;">
This text   has spaces     and 
 many many 
many oh so   
many
line breaks !!!     yeah
quit
</div>
in Insecure Explorer 6 does not give the expected results. Yes, the popular browsers fails to support it again.
 
Odd, I've use the in IE before and not had a problem. You say it does not give the "expected" results, what results DOES it give?


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Apparently it is the quirks vs. standards mode. I tried the exact simple code that I posted above and IE ignored all the white-space and replaced it with a single space. However, adding a doctype to it, helped IE6 cope with the code and display correctly. I apologize for speaking too soon about IE's capabilities. Looks like ver 6 is pretty decent in standards mode.
 
The problem (I think) you'll have with <pre> (or its CSS equivalent) is that it won't wrap lines to your page width, unless the user orignially pressed the return key at the end of each line, typewriter-style.

If they type a paragraph as one long string, only pressing the return key at the end of the paragraph, <pre> will put the whole paragraph on one line.

I think you're going to need to follow Tracy's orignal advice and scan the string, swapping carriage return characters for <br>s. Can't tell you how to do it in ASP, but it should be simple enough.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top