Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,762
    Thanks
    55
    Thanked 517 Times in 514 Posts

    building an array from text box input

    hello,

    I have a text input box where users can input values separated by a line break. What I need to do is to take those values and put them all into an array once they hit "submit".

    I can do this one line at a time, but I would like to be able to do it all in one hit.

    Can it be done in javascript?

    thanks in advance...

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,762
    Thanks
    55
    Thanked 517 Times in 514 Posts
    cancel that... got it with the ol' regex

    Code:
    var cities = document.getElementById("cities").value;
     var newcities=cities.replace(/\n|\r/g, '", "');
      points =['"'+newcities+'"'];

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,762
    Thanks
    55
    Thanked 517 Times in 514 Posts
    oops... spoke too soon... it only looked like an array

    had more luck with this:
    var newcities=cities.split(/\n|\r/g);
    Last edited by xelawho; 07-08-2011 at 09:06 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •