The effect is as shown:
code show as below:
Var ss_createdeelements = new object (); IMG_S_SRC = "btn_down_s.gif"; IMG_SRC = "btn_down.gif"; IMG_BLANK_SRC = "IMG_BLANK.GIF";
function unloadObjects () {try {if (SS_VAR && SS_VAR.SelectList) {for (key in SS_VAR.SelectList) {if (SS_VAR.SelectList [key]) {try {SS_VAR.SelectList [key] .select.setAttribute ( 'SS ', 0);} Catch (e) {}; delete ss_var.selectlist [key];}}}} Catch (e) {};} attachevent ("onunload", unloadObjects;
function SS_create (srcHTML, ListMax, bAutoDetect) {// property this.ssID = SS_VAR.SelectList.length; this.bOriginalSelect = (bAutoDetect && SS_ENV.IE_Version <5.5); this.select = SS_createElement (srcHTML); this.selectedIndex = This.Select.SelectedIndIndex; this.Options = this.select.Options; this.width = parseint (this.select.style.width); this.height = (this.select.Style.Height)? PARSEINT (this.select) .style.height): Ss_env.defaultHeight; this.OptionHeight = this.Height - 4; this.blistdown = (Listmax && '-' == Listmax.tostring (). Substr (0, 1))? false: true; THISTMAX = (! isnan (parseint (listmax)))? Math.abs (Listmax): 100;
THIS.TITLED; this.Titletable; this.titlewrapper; this.optionsdiv; this.optionswrapper; this.boptionStable; this.bfocused = false; this.bfocused = false; this.breverse = false;
// private method this.isThisEventToBeCanceled = SS_isThisEventToBeCanceled; this.toggleTitle = SS_toggleTitle; this.syncSelectedIndex = SS_syncSelectedIndex; this.toggleOptions = SS_toggleOptions; this.turnOnOption = SS_turnOnOption; this.turnOffOption = SS_turnOffOption; this.handleMousewheel = SS_handleMousewheel; this.handleOverTitle = SS_handleOverTitle; this.handleOutTitle = SS_handleOutTitle; this.handleOverOption = SS_handleOverOption; this.createTable = SS_createTable; this.createTitleDiv = SS_createTitleDiv; this.createOptionsDiv = SS_createOptionsDiv; this.createOptionTr = SS_createOptionTr; this.adjustOptionsDiv = SS_adjustOptionsDiv; this.syncOptions = SS_syncOptions; this.pressOption = SS_pressOption; this.moveOption = SS_moveOption; this.releaseOption = SS_releaseOption; this.pressTitle = SS_pressTitle; this.releaseTitle = SS_releaseTitle; // public method this.display = SS_display; this.insertOption = SS_insertOption; this.deleteOption = SS_DELETEOPTION; this.changeOptio N = ss_changeoption;
// initiate this.createTable (); this.select.setAttribute ( 'SS', this); if (! This.bOriginalSelect) this.select.onpropertychange = SS_handlePropertychange; SS_VAR.SelectList [this.ssID] = this;} function SS_DISPLAY () {document.write ("
function SS_cancelEvent (event) {event.cancelBubble = true; event.returnValue = false;} function SS_isThisEventToBeCanceled (event) {if ( 'object' == typeof (event)) {switch (event.type) {case 'mousedown': IF (! (Event.Button & 1)) Return True; Break; Case 'Mouseup': if (! (Event.Button & 1)) Return True; if (Ss_env.ie_version> = 5.5 && event.srcelement! = this ! .srcElementOfLastMousedown && this.srcElementOfLastMousedown = null) {this.srcElementOfLastMousedown = null; return true;} break; case 'mouseout': if ((SS_ENV.IE_Version <5.5 && event.srcElement == this.srcElementOfLastMousedown!)) return true Break; case 'mousemove': IF (ss_env.ie_version> = 5.5 && event.srcelement! = This.srcelementoflastMousedown && this.srcelementOflastMouseDown! =
null) return true; break;}} return false;} function SS_createElement (html) {SS_VAR.DivDummy.insertAdjacentHTML ( 'afterBegin', html); var oEl = SS_VAR.DivDummy.children (0); while (SS_VAR.DivDummy. Children.length> 0) {ss_var.divdummy.removechild (ss_var.divdummy.children (0));} Return OEL;} Function SS_BLUREXCEPT (Except) {ss_cancelevent (window.event);
Except = ('Number' == TypeOf (Except))? EXCEPT: -1;
Var bhastodetachevent = true; for (var i = 0; i IF (this.boriginalselect) return; IF (this.titletable.cells (0) .childNodes (0) .innerText! = this.Options [this.selected ".innertext) this.titletable.cells (0) .childnodes (0) .innertext = this.Options [ this.selectedIndex] .innerText; if (this.bExpanded) this.toggleOptions (false);} function SS_toggleTitle (bReverse) {this.bReverse = ( 'undefined' = typeof (bReverse)!) bReverse:?! (this.bReverse ); This.titletable.cells (0) .style.backgroundColor = this.breverse? S_env.creversebackground: '; this.titletable.cells (0) .Style.color = this.breverse? Ss_env.cr.reverseTextext :? '';} function SS_toggleOptions (bExpanded, bStrict) {(!! bStrict && this.bFocused) if {SS_blurExcept (this.ssID);} this.bExpanded = ( '! undefined' = typeof (bExpanded)) bExpanded: (! this.bexpanded); if (this.bexpanded) {this.adjustOptionsdiv (); this.optionsdiv.style.display = 'block'; if (! bstrict) {this.ToggletEtitle (FALSE); this.handleOverOption (this. .selectedindex);} this.handleutTitle ();} else {this.Optionsdiv.style.display = 'none'; if (! BSTRI) ct) {this.toggleTitle (true);}!} if (bStrict) {this.bFocused = true; if (SS_VAR.bEventAttached) {document.attachEvent ( 'onmousedown', SS_blurExcept);! document.attachEvent ( 'ondblclick' , SS_blurExcept); SS_VAR.bEventAttached = true;}}} function SS_handlePropertychange () {if ( 'propertychange' == window.event.type && 'selectedIndex' == window.event.propertyName) {var oSS = window.event. Srcelement.ss; oss.syncselectedIndex (); if (null = oSS.select.onchange!) oSS.select.onchange ();}} function SS_handleMousewheel (event) {var idx = this.selectedIndex; if ( 'mousewheel' == event.type && this.bFocused && this .Breverse) {for (var i = 0; i This.Optionsdiv.style.Width = this.width; this.Optionsdiv.style.Height = math.min (this.Options.Length, this.listmax) * this.OptionHeight 2; this.OptionSwrapper.Style.Height = this .Options.Length * this.OptionHeight; this.Optionsdiv.style.Overflowy = (this.Options.Length> this.listmax)? 'scroll': ''; var top = this.oft.offSettop; var left = this. Table.offsetleft; for (var = this.table.offSetParent; 'body'! = El.tagname && 'absolute'! = El.style.position && 'relative'! = El.style.position; EL = El.offSetParent) {if ('Table'! = EL.TAGNAME) {TOP = El.clienttop; Left = El.ClientLeft;} TOP = El.offSettop; Left = el.offsetleft;} this .Optionsdiv.style.top = (TOP THISTDOWN): (Top - Parseint (this.Optionsdiv.style.Height); this.Optionsdiv.style.Left = left; This.titleWrapper.Style.top = 0; this.titleWrapper.Style.Left = 0;} function ss_syncOptions () {if (this.boriginalselect) return; For (var i = 0; i This.SrcelementOflastMousedown = Event.srcelement; THIS.TOGGLEOPTIONS ();} function ss_releasetitle (event) {ss_cancelevent (event); IF (this.isthisEventtobecanceled (Event)) Return; THIS.SRCELEMENTOFLASTMOUSEDOWN = NULL;} Function SS_PRESSOPTION (Event) {ss_cancelevent (event); this.srcElementOfLastMousedown = event.srcElement;} function SS_moveOption (event) {SS_cancelEvent (event); if (this.isThisEventToBeCanceled (event)) return;! if ((event.offsetX> = 0 && event.offsetX <= this.OptionsTable .offsetwidth)))). THIS.HANDLEOVEROPTION (Math.FfSety / this.OptionHeight);} Function SS_RELEASEOPTION (Event) {ss_cancelevent (event); IF (this.isthisEventtobecanceled (Event)) Return; THIS.SRCELEMENTOFLASTMOUSEDOWN = NULL; if (event.offsetX> = 0 && event.offsetX <= this.OptionsTable.offsetWidth) {this.toggleOptions (false); this.select.selectedIndex = Math.floor (event.offsetY / this.OptionHeight);}} function SS_CREATETABLE () {this.table = ss_createElement (" "