Use the following code to divide some data using ',' from a statement:
var str = "Stack,Overflow,best,for,coder"
var matchesCount = str.split(",").length;
var vallueArray = str.split(',', matchesCount);
var value1= "";
for (var i = 0 ; i < vallueArray.length; i++) {
value1= value1+ vallueArray [i] + " ";
}
document.getElementById("txt1").value = value1;