Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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 October 3rd, 2004, 08:30 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default TextAreas And Arrays

I would like to populate a textarea with the contents of an array. The array is going to be populated by my users, who will be typing into a textbox and clicking a button. Each time they do this the value in the textbox should populate the next element of the array and update the display in the textarea. As I know nothing about arrays, any help would be great.

cheers
interrupt

__________________
\'sync\' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
 
Old October 4th, 2004, 12:49 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

you can iterate through the array and move through each and every items. You can do that using a for loop

   for (var i = 0; i < MyArr.length; i++)
   {
     var str = MyArr[i];
     TextArea1.value = TextArea1.value + str;
   }

Regards
Ganesh
 
Old October 4th, 2004, 06:28 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

.. or you can use join method:
Code:
var sArrayString = MyArr.join(",");
TextArea1.value - sArrayString;
--

Joe
 
Old October 4th, 2004, 07:08 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks guys. Can I use this method to also remove an element of the array? Ie:

1. User types into textbox and clicks go.
2. User makes a mistake and needs to remove the last element they entered, this would be the value in the textbox.

Thanks for your help guys
interrupt






Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace textboxes or textareas with some text amit_bhatia Beginning PHP 1 December 7th, 2004 11:32 AM
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM
Arrays tajin Excel VBA 0 June 20th, 2004 09:07 AM





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