Previous | Next | (P-PDF) JavaScript
Topic: Sort in Combo does not Sort
Conf: (P-PDF) JavaScript, Msg: 28223
From: george
Date: 10/6/2001 06:08 AM
> I fear that you'll tell me to go buy a reference
> book,
Good idea!
> but how would I programmatically sort the
> list? I've search several Java Guide(s) and there
> is no reference to it.
You might consider placing the items in a JavaScript array, and using the "sort" method of the array to sort it. Another advantage to using an array from the beginning is you can then use "setItems" using the array, instead of "insertItemAt". Things will be a bit more complicated if you want to include export values for the list items as well, but it can be done.
Here's some simple code that might get you started:
var f = getField("combo1");
var a1 = new Array();
a1[0] = "Lagavulin";
a1[1] = "Laphroaig";
a1[2] = "Ardbeg";
a1[3] = "Bowmore";
a1.sort();
f.setItems(a1);
Man, I need a drink. :^)
George