Simulate SELECT controls with DIV and SPAN

xiaoxiao2021-03-06  102

/ * Document Description Since SELECT does not be blocked in the menu, it will affect the effect. This program refers to the following example Definition Style.Width Width If the width of the width is defined, the width will be used to use this width Undefined Width 90Height Height If not, SELECT will be based on Options' number of automatic growth Options SELECT contents After transformation, it will become an array can be accessed via .Options [] [

Other transformation, please call the function Changetoselect, for example, ChangeToselect (CUL); defined in the style table, defined below. Solid INSet ButtonFace;}. Optiondiv {border: 1px solid black; border-top: 0px; position: absolute; Visibility: hidden;}. Optiondiv Div {font-size: 11px; font-family: Tahoma; padding-left: 8px; line-height: 130%; Cursor: default; width: 100%;}. defaultselect {font-size : 11px; Font-Family: Tahoma; Text-Align: Center; Border: 1px Solid White; Cursor: Default; Width: 77px;}. Defaultselect2 {font-size: 11px; font-family: tahoma; text-align: center ; border: 1px solid white; cursor: default;} arrow {font-family:. webdings; line-height: 13px; border: 2px outset buttonhighlight; background-color: #cccccc; width: 15px; text-align: center; CURSOR: DEFAULT; FONT-Size: 8px

Developer Li Shizhen to modify the blue rationality http://www.blueidea.com/tech/web/2003/1327.asp content to get this file * / function calletoselect (obj) {var selectdiv = document.createElement ("Table" ); obj.selectDiv = selectDiv; obj.options = eval (obj.options); selectDiv.style.width = obj.style.width; var selectDivTR = selectDiv.insertRow (); obj.selectDivTR = selectDivTR; var defaultValueTD = selectDivTR .insertcell (); obj.defaultvalueetd = defaultValueetd; var arrow = selectdivtr.insertcell (); arrow.style.color = 'black'; ///rrow.width="17px "; obj.Arrow = arrow; with (OBJ). Selectdiv) cellspacing = 0, cellpadding = 0, border = 0, classname = "selectdiv"; if (parseint (obj.style.width ') - PARSEINT (Obj.Style.Width ') == 0) with (Obj .defaultValueTD) innerText = obj.options [0] [0], className = "defaultSelect2"; else with (obj.defaultValueTD) innerText = obj.options [0] [0], className = "defaultSelect"; obj.value = Obj.Options [0] [1]; obj.text = obj.Options [0] [0]; obj.selectedIndIndex = 0; with (obj.Arrow) innerText = 6, classname = "arrow"; obj.Appendchild Selectdiv); // Outer Div Obj.OptionDIV = DOCUM Ent.createElement ("div"); obj.optiondiv.flag = "select"; // Set the coordinates and width of the drop-down menu option with (obj.optiondiv.style) {var select = obj.selectdiv; var xy = getSelectPosition (VAR XY = getSelectPosition select); pixelLeft = xy [0]; pixelTop = xy [1] select.offsetHeight; width = obj.selectDiv.offsetWidth; obj.optionDiv.className = "optionDiv"; backgroundColor = "white"; if (obj.height ! = null) Height = Obj.height; overflowx = "hidden"; overflowy = "auto";} // drop-down menu content obj.Options = new array ();

For (var i = 0; i

} Function moveWithOptions (bg, color) {with (event.srcElement) {style.backgroundColor = bg; style.color = color;}}} function getSelectPosition (obj) {var objLeft = obj.offsetLeft; var objTop = obj.offsetTop ; var objParent = obj.offsetParent; while (! objParent.tagName = "BODY") {objLeft = objParent.offsetLeft; objTop = objParent.offsetTop; objParent = objParent.offsetParent;} return ([objLeft, objTop]); } function selectedText () {var sel = event.srcelement.farther; sel.selectedindex = event.srcelement.index; sel.value = sel.options [sel.selected "[1]; SEL.TEXT = SEL.OPTIONS [SEL .selectedIndex] [0]; with (event.srcElement) {sel.defaultValueTD.innerText = innerText;} sel.optionDiv.style.visibility = "hidden"; //with(sel.defaultValueTD.style)background="highlight " Color = "white"; var t = ""; if (sel.onchange! = null) t = sel.onchange; if (sel.onchange! = null) T = SEL.Onchange; if (t! = '' ) {Var cmd = (t) .replace (/ this / gi, "sel"); //Document.execscrip (cmd, "javascript "); evAl (cmd);}} // javascri PT Document

转载请注明原文地址:https://www.9cbs.com/read-96832.html

New Post(0)