Hi,

I am modifying a bit of existing JavaScript that populates a <Select> list box. The reason is, that I would like the list box to be sorted by the text rather than the values. The "results" variable is populated with an array of htmlOptionElement(s), something I am a complete noob in. Based on a suggestion from the other side of the planet (Australia, this is significant because I am hoping to get an answer today and not on Monday ) I added the function(objA, objB) shown below to the result.sort method. It is not working and I am pretty sure it is because the "sort property" (MH_NO) is incorrect. I think it is supposed to be like the field name stored in the htmlOptionElement but I am completely unsure about that and I could not find any further info on it. Do you guys know what this "sort property" is and if it is a field name how I can extract that field name so I can see what it is supposed to be?

Thanks in advance for your help

Code:
function OnReadyStateChange() //Search for SN34N15
        {
            var ready = queryReqHandler.readyState;
            if (ready == READY_STATE_COMPLETE)
            {
                results = queryReqHandler.responseText.parseJSON();
                results.sort(function (objA, objB) {
                    if (objA.MH_NO < objB.MH_NO) {
                        return -1; //Less than 
                    } else if (objA.MH_NO > objB.MH_NO) {
                        return 1; //Greater than 
                    } else {
                        return 0; //Equal 
                    }
                });

                var resultSelect = document.getElementById("resultSelect");
                resultSelect.options.length = 0;
                for (var i = 0; i < results.length; i++) {
                    resultSelect.options[i] = new Option(results[i].displayValue, i, false, false);

                OnResultChange();
                document.getElementById("executeBtn").disabled = false;
                document.getElementById("busyImg").src = NOT_BUSY_IMAGE;
                queryReqHandler = null;
            }
        }