SHERIN AS SHERIN AS - 3 months ago 8
jQuery Question

variable values to store a array

how can I variable values to store a array?

Look my code:



var collection =normal,user,student ;
var array = [collection];
alert(array[0]);





In this case, alert would popup a normal,user,student. but i need an array such as array[0] get normal,array[1] get user,array[2] get student like that
how it is possible

Is there any chance to convert such variable into a JS array?

Answer
var collection = "normal,user,student";
var jsarray = collection.split(",");
alert(jsarray[0]);
alert(jsarray[1]);
alert(jsarray[2]);