★ wanayoo — archive 1999 http://www.webtechniques.com/sourcecode/1999/11/junk/4.lstNouvelle recherche | Portail wanayoo

 
| home | current issue | archives | source code | events | demo express | search | editorial calendar | advertising | customer service | author guidelines | jobs | about

S O U R C E   C O D E / 1999 / 11 / junk / 4.lst

// SelectSort.js

wCLASS['SelectSort'] = {tag:'SELECT'};
function SelectSort(obj, method)
{
    this.base    = obj;
    this.sortMethod  = (method == null)? 'alpha': method;
    this.sortOptions = _sortOptions;
    this.sortOptions();
}
function _sortOptions()
{
    var a = new Array;
    var b = this.base.options;
    for(var i = 0; i < this.base.length; i++)
        a[i] = new Option(b[i].text, b[i].value);

    a.sort( (this.sortMethod == 'alpha')? _alphaSort: _numSort );               
    for(var j = 0; j < a.length; j++)
        b[j] = new Option(a[j].text, a[j].value);    
}                        
function _alphaSort(x, y)
{                
    return (x.text > y.text)? 1: -1;
}
function _numSort(r, t)
{            
    return parseInt(r.text) - parseInt(t.text);
}


| home | current issue | archives | source code | demo express | events | search | editorial calendar | advertising | customer service | author guidelines | jobs | about




Entire contents copyright 1996-2000 CMP Media Inc.
Read our privacy policy.