|
Subject:
|
Read textarea
|
|
Posted By:
|
darkhalf
|
Post Date:
|
7/5/2006 12:17:21 PM
|
Hi,
Silly question, but how can I itterate through a textarea and read it line by line... Say that in the text area there was 5 lines, I was to be able to pull each of those 5 lines to play around with.
|
|
Reply By:
|
panacea
|
Reply Date:
|
7/12/2006 5:13:58 AM
|
Text areas can be multiple lines either through the wrapping of one line over to another, or by the user pressing the enter key. To divide lines based on the enter key, use the Javascript split() function (http://www.w3schools.com/jsref/jsref_split.asp) with separator="\n". Determining line wrap locations is much more difficult, as you'll have to reverse-engineer the line wrapping algorithm, which may be different depending on the browser, to find whitespace locations where wrapping could occur.
Good luck! :)
Jon Emerson http://www.digg.com/users/panaceaa/profile
|