home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

textarea's understanding linebreaks

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 2110
Discussions: 200,948, Posts: 2,379,414, Members: 246,309
Old July 22nd, 2005, 02:57 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Jul 2005
Posts: 2
textarea's understanding linebreaks

Hello,
I'm working on a messaging system and I have a textarea that has some text where I do:
var text = window.document.message.reply.value;
to get the text,

but when the other person receives the message it is all on ONE line - it doesn't recognize line-breaks at all.

A second problem arises when I manually enter in line breaks "\n" and whatever else, and the message shows up fine, except the reply button will not work - there seems to be an error in the javascript because of the linebreaks - i imagine it happens because each line of the javascript is ended with text, instead of double quotes and a semicolon.

Any help would be appreciated,
Thanks!

David
Aikon3390 is offline   Reply With Quote
Old July 22nd, 2005, 06:05 PM     #2 (permalink)
Banned
 
Iturea's Avatar
 
Join Date: Jan 2004
Location: Earth
Posts: 420
Smile
Just a thought :-)

If the whole textarea is stored in one variable then yes you will have one big string. You will need to split that string up like you see in the code below. You can then use a loop to illiterate through the array of strings and define how many words you would like per line and create your own wrap effect.

source: http://www.quirksmode.org/js/strings.html#split
Code:
var b = 'I am a JavaScript hacker.'
var temp = new Array();
temp = b.split(' ');

Now the string has been split into 5 strings that are placed in the array temp. The spaces themselves are gone.

temp[0] = 'I';
temp[1] = 'am';
temp[2] = 'a';
temp[3] = 'JavaScript';
temp[4] = 'hacker.';
Iturea is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
understanding dvd rw views1 General Tech Discussion 5 December 29th, 2004 09:27 AM
Help understanding some java! weezal100 Webmastering and Programming 1 February 12th, 2004 07:42 PM
Need help understanding FSB, etc. jmoore2001 Motherboards 15 September 1st, 2003 02:06 AM
Understanding an IP number ClubMed General Tech Discussion 3 January 5th, 2003 04:19 AM
Understanding /dev and /proc :) otheos Applications and Operating Systems 10 April 7th, 2002 03:19 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Making Health Care Worse (175)
The disrespect of Obama by Russian .. (26)
Is It Just Me? (2940)
Wireless Televisions. (12)
windows 7 problem (7)
CPU fan stops spinning randomly (8)
Regular Build (6)
Is the PSU I received dead? (12)
radeon x850xt platinum & shader.. (5)
Print spooler problem (15)
HIS HD5770 graphic card question (15)
windows vista security holes (9)
Install XP pro and a Vista laptop ?.. (11)
Dept. of HS: NSA 'Helped' Develop V.. (15)
Recent Discussions
Multiple Restarts Required at Boot (1)
For Sale BFG GTX285 OC2 with 10 year .. (3)
Point and Shoot Camera Suggestions. (3)
How to convert MP3's (4)
Wireless Televisions. (12)
Graphics Card Upgrade Question (3)
Laptop with wireless problem. (2)
Internet Lost (1)
Hp Artist Edition + Matching Bag (0)
My monitor won't turn on after instal.. (0)
Asus P4G8X Mobo (6)
radeon x850xt platinum & shader 3 (5)
Xbox 360 GTA: SA disk error (1)
Is the PSU I received dead? (12)
windows 7 internet problem (5)
BSOD On Startup (ntoskrnl.exe) (2)
Print spooler problem (15)
Have you switched yet? (86)
screen resolution vs monitor size (2)
sms storage to PC (0)
Regular Build (6)
Open With ..... Win7 (0)
java code for fibonacci (1)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (35)
windows 7 problem (7)


All times are GMT -4. The time now is 10:08 PM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28