Solved

Problem in displaying Textarea contents

Posted on 2003-10-22
10
314 Views
Last Modified: 2010-05-19
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
Comment
Question by:sursatraj
10 Comments
 
LVL 17

Expert Comment

by:dorward
ID: 9604762
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
 

Author Comment

by:sursatraj
ID: 9604844
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
 

Author Comment

by:sursatraj
ID: 9604907
Hi,

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

Rgds
Surjit
0
 
LVL 17

Expert Comment

by:dorward
ID: 9605035
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
 

Expert Comment

by:cliffhanger9
ID: 9607366
use the wrap property of the textarea tag
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Expert Comment

by:fozylet
ID: 9610312
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
 

Author Comment

by:sursatraj
ID: 9625922
<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
 

Author Comment

by:sursatraj
ID: 9625929
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
 
LVL 17

Accepted Solution

by:
dorward earned 250 total points
ID: 9625976
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
 

Author Comment

by:sursatraj
ID: 9626053
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now