Arrays can be declared a couple of ways
var array = new Array();
or
var array = [ ]; //just short hand
So the first time the param is encountered a the value was stored in an
array in the following line[color=blue][color=green]
> > params[nameVal[0]] = [nameVal[1]];[/color][/color]
this could also be written[color=blue][color=green]
> > params[nameVal[0]] = new Array(nameVal[1]);[/color][/color]
push is a method on Array objects that automatically adds a new entry to the
end of an array. so instead of increasing the number of
members in an array by using:
myArray[myArray.length] = new Object();
you can simply use:
myArray.push(new Object());
For complete documentation check out
http://devedge.netscape.com/library/...nce/array.html http://devedge.netscape.com/library/.../contents.html
"johkar" <nosendjunk@link.net> wrote in message
news:jtumb.1149$Px2.846@newsread4.news.pas.earthli nk.net...[color=blue]
> Thanks for the reply. Where is the new array declared? What is push, and
> what does it do? Support?
>
> John
>
> "Oz" <oz@synovic.com> wrote in message
> news:kcKdnfTd2aRo4gSiRVn-uA@comcast.com...[color=green]
> > Instead of storing just the value, store the value as an Array. That way[/color][/color]
a[color=blue][color=green]
> > single param can have multiple values.
> >
> > change:[color=darkred]
> > > for ( var i=0; i<nameValuePairs.length; i++ ) {
> > > nameVal = nameValuePairs[i].split('=');
> > > params[nameVal[0]] = nameVal[1];
> > >
> > > }[/color]
> >
> > To:
> >
> > for ( var i=0; i<nameValuePairs.length; i++ ) {
> > nameVal = nameValuePairs[i].split('=');
> > if (params[nameVal[0]] == null) {//param doesn't exist so create[/color][/color]
a[color=blue][color=green]
> > new array
> > params[nameVal[0]] = [nameVal[1]];
> > }else{ //param already exists so add to the array
> > params[nameVal[0]].push(nameVal[1]);
> > }
> > }[/color]
> snip
>
>
>[/color]