Solved

Problem in displaying Textarea contents

Posted on 2003-10-22
10
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

726 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