|
-
Jan 3rd, 2002, 11:41 AM
#1
Thread Starter
Evil Genius
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 ?!?!? :
Code:
UndefinedOne
Two
Three
-
Jan 3rd, 2002, 11:46 AM
#2
Frenzied Member
*shrug*
Try setting strTemp to and empty string before the loop.
I don't guess JavaScript has a += operator.
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
-
Jan 3rd, 2002, 11:48 AM
#3
Thread Starter
Evil Genius
Yeah, that did it, thanks !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|