• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

Problem in displaying Textarea contents

Hi,

I have described the problem below in points.Pls guide me to resovle this issue.

1. Copied data from Microsoft Word and pasted into the TextArea in the HTML Form
2. Saved TextArea contents into the database.
3 Retrieved Teaxtarea contents from the datbase and displayed on the html.
4. Text is displayed as long lines...horizontal scrolling is nuiscance to read long lines.

How should I restrict the lines so that horizontal scrolloing is avoided while displaying on the browser.


Rgds
Surjit
0
sursatraj
Asked:
sursatraj
1 Solution
 
dorwardCommented:
Its hard to know what's causing the problem without seeing the code, but my guess is that you are wrapping the data in a <pre> element. If you don't put line breaks then it will expand, so don't use a <pre> element.
0
 
sursatrajAuthor Commented:
Hi Dorward,

Ur r right...i am displaying data within pre tags to maintain the entered data as it is...

If I am displaying data without pre tags then it will be like big paragraph with no line breaks

Rgds,
Surjit
0
 
sursatrajAuthor Commented:
Hi,

Is there any workaround to avoid horizontal scrolling and maintain the format as enetred in the textarea.

Rgds
Surjit
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
dorwardCommented:
If the data is entered as one long line, then its impossible to avoid horizontal scrolling and keep it as it is - if you stop the horizontal scrolling, then the data will not be displayed as entered!

Probably you want to add a line break <br> to the end of each line in your (server side) script, or maybe wrap it in paragraph tags. Without seeing the data, its difficult to tell.
0
 
cliffhanger9Commented:
use the wrap property of the textarea tag
0
 
fozyletCommented:
Instead of <pre> try using

Replace(message_body,vbCrLf,"<br>")

if you're using ASP.
where message_body is the message you retrieve from the db.
0
 
sursatrajAuthor Commented:
<html><head><title>Testing Textarea</title></head><body>
<%
If request.Form("Submit") = "Submit" Then
      Dim output
      output = request.Form("textarea")      
End if
%>
<pre><%=output%></pre>
<form name="form1" method="post" action="">
  <textarea name="textarea" cols="20" rows="5"></textarea>
  <input type="submit" name="Submit" value="Submit">
</form>
</body></html>

Below is the junk line which checks for textarea of  "Posting Comment" I just wanted to know how Expert-exchange handles this

sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
0
 
sursatrajAuthor Commented:
Hi

When i tried above line "sssssssssss...." even exeprts-exchange doesn't take care of Text area contents...

So I think i have to program on the Server side

Rgds
Sujit
0
 
dorwardCommented:
Yes, the safe way is to check the length of each 'word' and should any exceed the limit, return it to the user with an error:

Sorry, 'words' longer then 25 characters are not allowed. Please insert some spaces to allow the content to wrap.

If you expect to be handling URIs you should take special steps to handle them. Possibly by allowing users to specify different display text, or by automatically cutting out the middle and sticking ... in its place. i.e.

http://www.veryveryveryveryverylong.com/long/long/long/long/long/long/long/long/long/long/this/is/rather/long/isnt/it?

becomes

<a href="http://www.veryveryveryveryverylong.com/long/long/long/long/long/long/long/long/long/long/this/is/rather/long/isnt/it?">http://www.veryvery.../long/isnt/it?</a>
0
 
sursatrajAuthor Commented:
Hi

I think the best way is display the contents again in another text area...so that we can avoid horizontal scrolling

Rgds
Surjit
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now