[thelist] accessing globla JS array from function (was: Re: sql order by sizes)

Brian Cummiskey brian at hondaswap.com
Sat Jul 7 20:34:23 CDT 2007

> Should i not bother with the sub query as Matt suggested, and instead 
> use the power of the JS array for my sorting?
ok, i've decided to go the JS route, and now i'm in a bind trying to 
access the array.

my server-side classic asp script creates the following JS embedded 

<script type="text/javascript">
document.getElementById("selcolor").options[0] = new Option('Select Color', '');
document.getElementById("selcolor").options[1] = new Option('FUCHSIA', 'FU');
document.getElementById("selcolor").options[2] = new Option('HONEYDEW', 'HO');
document.getElementById("selcolor").options[3] = new Option('LIPSTICK', 'LI');
document.getElementById("selcolor").options[4] = new Option('NEW ROYAL', 'NR');
document.getElementById("selcolor").options[5] = new Option('PINK QUARTZ', 'PQ');
document.getElementById("selcolor").options[6] = new Option('STEEL', 'ST');

var FU=new Array();
FU = ["2XL","LG","MD","SM","XL","XS"]

var HO=new Array();
HO = ["2XL","LG","MD","SM","XL","XS"]

var LI=new Array();
LI = ["2XL","LG","MD","SM","XL","XS"]

var NR=new Array();
NR = ["2XL","LG","MD","SM","XL","XS"]

var PQ=new Array();
PQ = ["2XL","LG","MD","SM","XL","XS"]

var ST=new Array();
ST = ["2XL","LG","MD","SM","XL","XS"]


I plan to use some sorting on it later on, as the original question suggested.   But, now i'm dealing with a larger issue.

in a separate externally linked in the head script, i'm trying to grab the FU/HO/LI/etc array where FU/HO/LI/etc is the passed in colorcode var to the function:

function popsizes(colorcode) {	
	elem = document.getElementById("selcolor");		//selcolor is the ID of my select form element

	for (i=0; i<elem.options.length; i++)
		sizelist = colorcode[i];
		//alert("size =" + sizelist);
		document.getElementById("selsize").options[i] = new Option(sizelist);

unfortunately, this is giving me "F" and "U" and then 'undefined' for 
the rest of the loop for the colorcode (as its thinking its just a text 
string) instead of the actual array values.
I'm obviously not accessing this array properly.

The event won't get called until onchange, so the loading order factor 
shouldn't be an issue

any pointers?

More information about the thelist mailing list