473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Intuitive text box

Hello Javascript gurus. I have a question about a Textarea. I am typing
text or copying and pasting text into a textarea. This text contains
line breaks, paragraphs, bullets, etc. In the Textarea it looks
correct, but when saved to a database and displayed later it is all
rendered in 1 big paragraph - obviously because it lacks the proper
tags. Is there a way to get it to save with tags that correspond to its
various paragraphs, breaks, etc.? Like it literally inserts the <pand
<brfor me? Thanks - MG

Sep 18 '06 #1
5 1303
On Mon, 18 Sep 2006 08:31:47 -0700, Window Frog wrote:
Hello Javascript gurus. I have a question about a Textarea. I am typing
text or copying and pasting text into a textarea. This text contains
line breaks, paragraphs, bullets, etc. In the Textarea it looks correct,
but when saved to a database and displayed later it is all rendered in 1
big paragraph - obviously because it lacks the proper tags. Is there a
way to get it to save with tags that correspond to its various
paragraphs, breaks, etc.? Like it literally inserts the <pand <brfor
me? Thanks - MG
What language are you using to write and read to and from the database?
PHP has a function to convert the formatting pretty flawlessly for textbox
data that's been stored in a database: nl2br(); (new line to <br>). I'm
not sure if there's and equivalent JavaScript function or if you'd have to
do some Regex.
Sep 18 '06 #2

Ivan Marsh wrote:
On Mon, 18 Sep 2006 08:31:47 -0700, Window Frog wrote:
Hello Javascript gurus. I have a question about a Textarea. I am typing
text or copying and pasting text into a textarea. This text contains
line breaks, paragraphs, bullets, etc. In the Textarea it looks correct,
but when saved to a database and displayed later it is all rendered in 1
big paragraph - obviously because it lacks the proper tags. Is there a
way to get it to save with tags that correspond to its various
paragraphs, breaks, etc.? Like it literally inserts the <pand <brfor
me? Thanks - MG

What language are you using to write and read to and from the database?
PHP has a function to convert the formatting pretty flawlessly for textbox
data that's been stored in a database: nl2br(); (new line to <br>). I'm
not sure if there's and equivalent JavaScript function or if you'd have to
do some Regex.
Hey there, I'm using VBScript to store to the db and then again to
display that data. It's going into MySQL in a TEXT type field.

Sep 18 '06 #3

Window Frog wrote:
Hello Javascript gurus. I have a question about a Textarea. I am typing
text or copying and pasting text into a textarea. This text contains
line breaks, paragraphs, bullets, etc. In the Textarea it looks
correct, but when saved to a database and displayed later it is all
rendered in 1 big paragraph - obviously because it lacks the proper
tags. Is there a way to get it to save with tags that correspond to its
various paragraphs, breaks, etc.? Like it literally inserts the <pand
<brfor me? Thanks - MG


function nl2br_js(myString) {
// 02-18-06 - this function imitates the PHP command nl2br, which
finds newlines in a string
// and replaces them with newlines plus HTML BR tags. It is the
easiest way to create the
// appearance of paragraphs when people are creating web pages by
typing text into a form.
var regXString = "\\n"
var regX = new RegExp(regXString, "g");
var replaceString = "<br /\n";
return myString.replace(regX, replaceString);
}

Sep 19 '06 #4
JRS: In article <11**********************@k70g2000cwa.googlegroups .com>,
dated Mon, 18 Sep 2006 20:26:51 remote, seen in
news:comp.lang.javascript, Jake Barnes <lk******@geocities.composted :
// 02-18-06 - this function imitates the PHP command nl2br, which
^^^^^^^^
When posting to an international medium, please convert such ludicrous
date formats to something that is understandable everywhere without
ambiguity.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Sep 20 '06 #5

Dr John Stockton wrote:
JRS: In article <11**********************@k70g2000cwa.googlegroups .com>,
dated Mon, 18 Sep 2006 20:26:51 remote, seen in
news:comp.lang.javascript, Jake Barnes <lk******@geocities.composted :
// 02-18-06 - this function imitates the PHP command nl2br, which
^^^^^^^^
When posting to an international medium, please convert such ludicrous
date formats to something that is understandable everywhere without
ambiguity.

My bad. So sorry.

Sep 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: elena | last post by:
I have a test online that measures cognitive style. It determines whether the participant has an intuitive or analytical learning style. It takes about 5 minutes. It's here: http://www.elena.com...
3
by: Xerxes | last post by:
Hi, I need help in setting up a page where the text wraps around an image. Right now, I am using table, with text in one <td> and the image in the adjacent <td>. The problem is when the text is...
2
by: Macsicarr | last post by:
Hi All Wonder if you could help me. I have created a CMS system that allows the user to enter text and pic 'tags' for their own About us page, eg text.... text.... text.... text.......
2
by: Paul Brown | last post by:
Thanks for various responses - my feeling is that the cost benefit ratio is now approaching the noise level asymptote, though there was at least one good point : > compressed plain-text copy of...
8
by: masood.iqbal | last post by:
All this time I was under the illusion that I understand the concept of multi-dimensional arrays well ---- however the following code snippet belies my understanding. I had assumed all along...
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
3
by: jweinberg1975 | last post by:
I would like for users to be able to select from a small number of options that come from a little drop down menu which then closes. .....
3
by: bbepristis | last post by:
Hey all I have this code that reads from one text file writes to another unless im on a certian line then it writes the new data however it only seems to do about 40 lines then quits and I cant...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.