Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 5th, 2006, 12:17 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default Read textarea

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.

 
Old July 12th, 2006, 05:13 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab function + <textarea></textarea> Adam H-W HTML Code Clinic 0 April 24th, 2007 10:36 AM
regarding textarea in asp nkramanmca Classic ASP Components 4 January 24th, 2005 03:53 AM
Apostrophe in textarea Renu ASP.NET 1.0 and 1.1 Basics 3 September 8th, 2004 02:13 PM
display vbCrLf's from textarea to textarea mat41 Classic ASP Basics 8 June 10th, 2004 12:19 AM
TextArea microchip Classic ASP Databases 2 March 17th, 2004 11:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.