-
another js one - Array Q
Code:
Function CreateInitialArray() {
var intCounter;
var strTemp;
for(intCounter=0; intCounter<theform.lstbox.options.length; intCounter++) {
strAry[intCounter] = theform.lstbox.options[intCounter].text;
strTemp = strTemp + strAry[intCounter] + "\n";
}
alert(strTemp);
}
Hi all. I'm using that one to loop through a <Select> listbox on a web page, and adding each line or entry from this listbox into an array. A string's then created of all the array elements before showing this in a messagebox.
I keep getting "undefined" before the first entry though - below is an example of how this comes out. Whats the reasoning behind this please ?!?!? :confused: :
Code:
UndefinedOne
Two
Three
-
*shrug*
Try setting strTemp to and empty string before the loop.
I don't guess JavaScript has a += operator.
-
Yeah, that did it, thanks !