...

View Full Version : building an array from text box input



xelawho
07-08-2011, 05:45 PM
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...

xelawho
07-08-2011, 06:18 PM
cancel that... got it with the ol' regex :D



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

xelawho
07-08-2011, 08:58 PM
oops... spoke too soon... it only looked like an array :mad:

had more luck with this:
var newcities=cities.split(/\n|\r/g); :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum