File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes separate data with comma separated values and store them in a array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "separate data with comma separated values and store them in a array" Watch "separate data with comma separated values and store them in a array" New topic
Author

separate data with comma separated values and store them in a array

Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Hi

My requirement is this that i have to iterate over the values which are comma separated and put them in a array so that i can iterate over them
again to put them in a dropdwon box.

Detailed:

I have a javascript function in which i gettting a var with values separated by ","(comma)

for e.g var data = TA,FA,SA,BA,SA;

Now i want to separate these values and store them in a javascript array(i.e dataArray) so that i can iterate those and put in dropdwon box using some thing like below.


where drpDwn is my var drpDwn = document.getElementById("id of the dropdown");

here is my addOption function.



so basically i need to know the way of separating the data and storeing them in the javascript array.
Prashant Langade
Ranch Hand

Joined: Jul 01, 2009
Posts: 71
Hey good news!!


I go the solution

var myArray = myString.split(",");

I need to use this in order to split the string.

Thanks and Regards
Prashant
Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

Hey,

There is a js function [ib]split()[/b] function which will do this.
See http://www.w3schools.com/jsref/jsref_split.asp

Sean


I love this place!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: separate data with comma separated values and store them in a array
 
Similar Threads
Dynamic drop down list from an array
Drop Down List do not create when more elements added
Retaining javascript values in jsp
putting values from ArrayList to optionlist/dropdownlist
JSP variable typical problem