As you've seen this isn't the way to go about it. How is the request parameter "names" formatted? Based on your code it sounds like it would be something like
names=Bob&names=Sue&names=Barf
is this correct? That's kind of a weird URL but it can be dealt with entirely in JavaScript
:
var arrayJS=new array();
var searchString = document.location.search;
// strip off the leading '?'
searchString = searchString.substring(1);
var nvPairs = searchString.split("&");
for (i = 0; i < nvPairs.length; i++) {
var nvPair = nvPairs[i].split("=");
if( nvPair[0] === 'names' ) {
arrayJS.push( nvPair[1] );
}
}
This code was derived from
here.