当前位置:Gxlcms > JavaScript > select发展史

select发展史

时间:2021-07-01 10:21:17 帮助过:13人阅读

本文旨在大家对select和模拟select有一个全面地了解,使此项技术能发挥出更高的水平。

最初的select的确很平淡,就是一个下拉选项列表:

<style>
select,option {background-color:lime}
</style>
<select>
<center>
<option>1
<option>2
<option>不是一样的嘛</select>

日久天长之后,人们对select要求高了,要修一修边幅:

<br><br>
<script>
i=1;
</script>
<center>
<form name="form1">
  <select name="select01">
    <option>11111 111111 111111111111</option>
    <option>2222222</option>
    <option>333333</option>
    <option>4444444</option>
  </select>
<span style="position:relative;left:-23px;width:17px;height:17px;font:7px 'wingdings 3';color:#cc0000;background:cyan;border:2px outset;text-align:center;padding-top:3px;cursor:default" onclick="if(i>=document.form1.select01.options.length){i=0}document.form1.select01.options[i].selected=true;i++">q
<iframe src="" style="position:absolute;top:0;left:0;z-index:-1; width:15px;height:15px;filter:alpha(opacity=0))" frameborder="0"></iframe>
</span>
</form>
<br><br><br>




<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.table1{background-color:white;FONT-FAMILY: Courier New, Courier;font-size:12px}
.td_out{FONT-FAMILY: Courier New, Courier;font-size:12px;color:#000000;height:15px;border:1 solid #ffffff;}
.td_over{FONT-FAMILY: Courier New, Courier;font-size:12px;cursor:default;background-color:#3366cc;border:1 solid #000000;color:#ffffff;height:15px}
.slv{vertical-align:bottom;FONT-FAMILY: Courier New, Courier;font-size:12px;border-left-width:0;border-top-width:0;border-bottom-width:0;border-right:0 solid #000000;vertical-align:middle;height:18px;color:#000000;}
.down{position:relative;left:-2px;font-size:11px;vertical-align:middle;width:16;height:16;color:#2050b0;background-color:#D0DFF7;border:1 solid #9fA3Ce;writing-mode:tb-rl;font-weight:bold;
}
.selp{
position:absolute;z-index:1000;overflow-x:hidden;border-left:1 solid #000000;border-bottom:1 solid #000000;border-right:1 solid #000000;
SCROLLBAR-FACE-COLOR: #d0dff7; 
SCROLLBAR-HIGHLIGHT-COLOR: #d0dff7; 
SCROLLBAR-SHADOW-COLOR: #FFFFFF; 
SCROLLBAR-3DLIGHT-COLOR: #FFFFFF; 
SCROLLBAR-ARROW-COLOR: #ffffff; 
SCROLLBAR-TRACK-COLOR: #ffffff; 
SCROLLBAR-DARKSHADOW-COLOR: #d0dff7;}
</style>
<script language="JavaScript">
document.onclick=hiddenDiv;
function getDivCount() {
 var arr=document.all; 
 re=0;
 for (i=0;i<arr.length;i++) {
  str=arr[i].id;  
  if (str.indexOf("ZfDiv_")==0) {   
   re++;  
  }
 } 
 return re;
}

function getI(ObjId) {//取得objId的最后一位数字
 for (i=0;i<ObjId.length;i++) {
  if (ObjId.charAt(i)=="_") return ObjId.substr(i+1,ObjId.length-1);
 }
 return 0;
}

function select_edit(TextObj){//鼠标经过高亮度 
 TextObj.focus();TextObj.select();
}

function checkValue(ID){   
 var sl=document.all["ZfText_"+ID]; 
 var sv=document.all["ZfDiv_"+ID];
 var da=document.all["ZfData_"+ID];   
 sv.style.display=''
 
 for(i=0;i<da.rows.length;i++)da.rows[i].style.display=''
 
 for(i=0;i<da.rows.length;i++){
  if(da.rows[i].cells[0].innerText.indexOf(sl.value)!=0)da.rows[i].style.display='none';
  getPosition(ID);
 } 
}

function getL(e){
 var l=e.offsetLeft;
 while(e=e.offsetParent){
  l+=e.offsetLeft;
 }
 return l
}
function getT(e){
 var t=e.offsetTop;
 while(e=e.offsetParent){
  t+=e.offsetTop;
 }
 return t
}

function getPosition(ID){ 
 var sv=document.all["ZfDiv_"+ID];
 var sl=document.all["ZfText_"+ID];
 var spn=document.all["ZfSpan_"+ID];
 var da=document.getElementById("ZfData_"+ID);
 sv.style.pixelWidth=spn.offsetWidth;
 da.style.pixelWidth=sv.offsetWidth;
 sv.style.pixelLeft=getL(spn);
 sv.style.pixelTop=getT(spn)+sl.offsetHeight+3;
 if(da.offsetHeight>200){
  sv.style.pixelHeight=200;
  sv.style.overflowY='scroll';
 }
 else {
  sv.style.pixelHeight=da.offsetHeight;
  sv.style.overflowY='hidden';
 }
}

function dropDown(ID){ 
 var sv=document.all["ZfDiv_"+ID]
 var tb=document.all["ZfData_"+ID]
 
 if(sv.style.display=='none'){  
  sv.style.display='';  
  for(i=0;i<tb.rows.length;i++)tb.rows[i].style.display=''
  getPosition(ID);  
 } else {  
  sv.style.display='none';
 }
}//下拉摸拟层

function hiddenDiv(){
 var o=window.event.srcElement.id;
 var tb 
 var sv 
 if(o=="") {
  for (j=0;j<getDivCount();j++) {
   tb=document.getElementById('ZfData_'+j);
   sv=document.getElementById('ZfDiv_'+j);   
   for(i=0;i<tb.rows.length;i++) tb.rows[i].style.display='';
   sv.style.display='none';   
  }
  
 }

}//隐藏模拟层


function setValue(obj){
var i=getI(obj.parentElement.parentElement.parentElement.id);
//alert(obj.parentElement.parentElement.parentElement.id);

var sl=document.all["ZfText_"+i];
var sv=document.all['ZfDiv_'+i];
sl.value=obj.innerText;
sv.style.display='none';
//sldIndex=obj.parentElement.rowIndex;
}//给文本框赋值

function over(obj){
 obj.className="td_over"
 obj.title=obj.innerText
 obj.focus();
}//鼠标经过变色

function out(obj){
 obj.className="td_out"
}//鼠标离开还原

function String.prototype.Trim(){return this.replace(/(^\s*)|(\s*$)/g,'')}//自定义去空格函数Trim()


//增加list的接口,ID表示该组控件是页面中的第几个
function add(v,ID){
var sv=document.all['ZfDiv_'+ID];
if(!v.Trim()){return;}
var tb=document.all['ZfData_'+ID];
var c=tb.insertRow(tb.rows.length).insertCell();
c.innerHTML='<nobr>'+v.Trim()+'</nobr>';
c.onmouseover=new Function("over(this)");
c.onmouseout=new Function("out(this)");
c.onclick=new Function("setValue(this)");
c.className="td_out";
v='';
}
//增加inpnubox的接口,在页面中产生一个inputbox控件,下拉列表为空
function addText(name,DefValue) {
 var i=getDivCount();
 document.write('<span id="ZfSpan_'+i+'" style="border:1 solid #9CA0CB">');
 document.write('<input type="text" value="'+DefValue+'" name="'+name+'" id="ZfText_'+i+'" ondblclick="ZfDrop_'+i+'.click()" class="slv" onmouseover="select_edit(this)"  onkeyup="checkValue('+i+')"><input type=button id="ZfDrop_'+i+'" value=">" onclick="this.hideFocus=true;dropDown('+i+');" class="down" onmouseover="this.style.backgroundColor=#EEF3FD" onmouseout="this.style.backgroundColor=\'\'" onmousedown="this.style.backgroundColor=#ABC4F5" onmouseup="this.style.backgroundColor=\'\'"></span>');
 document.write('<p id="ZfDiv_'+i+'" class="selp" style="display:none;"><table id="ZfData_'+i+'" onselectstart="return false" border="0"  cellspacing="0" cellpadding="0" class="table1"></table></p>');
}

 

</script>
</head>
<body>

<script language="JavaScript">
addText("name1","a");
add("1234",0);
add("1234",0);
addText("name1","a");
add("1234",1);
add("1234",1);
</script>

要加一些链接,变成菜单:

<STYLE>
body { cursor: url(http://vip.6to23.com/candylau/image/xiucursor.cur)}
</STYLE>




<style>
.select{border: 0 inset buttonface; width: 100; font: icon; cursor: default;}
.selected{border: 0 inset buttonface; background: window; padding: 0; font: icon;}
.selectTable{height: 100%; width: 100%;border: 2 inset buttonhighlight; background: buttonface;}
.option    {font: icon; padding: 1; padding-left: 3; padding-right: 3; width: 100%;}
.dropDown{position: absolute; visibility: hidden; width: 100%;border: 1 solid windowtext; padding: 0;background: window;}
.select .button    {width: 16px; height: 5; font-family: webdings; padding: 0;font-size: 11px; border: 2 outset buttonhighlight;}
</style>

<script type="text/javascript">
var overOptionCss = "background: highlight; color: highlighttext";
var sizedBorderCss = "2 inset buttonhighlight";
var globalSelect;
var ie4 = (document.all != null);
var q = 0;
function initSelectBox(el) {
    copySelected(el);
    var size = el.getAttribute("size");
    el.options = el.children[1].children;
    el.selectedIndex = findSelected(el);
    el.remove = new Function("i", "int_remove(this,i)");
    el.item   = new Function("i", "return this.options[i]");
    el.add    = new Function("e", "i", "int_add(this, e, i)");    
    el.options[el.selectedIndex].selected = true;

    dropdown = el.children[1];

    if (size != null) {
        if (size > 1) {
            el.size = size;
            dropdown.style.zIndex = 0;
            initSized(el);
        }
        else {
            el.size = 1;
            dropdown.style.zIndex = 99;
            if (dropdown.offsetHeight > 200) {
                dropdown.style.height = "200";
                dropdown.style.overflow = "auto";
            }
        }
    }
    
    highlightSelected(el,true);
}

function int_remove(el,i) {
    if (el.options[i] != null)
        el.options[i].outerHTML = "";
}

function int_add(el, e, i) {
    var html = "<p class='option' noWrap";
    if (e.value != null)
        html += " value='" + e.value + "'";
    if (e.style.cssText != null)
        html += " style='" + e.style.cssText + "'";
    html += ">";
    if (e.text != null)
        html += e.text;
    html += "</p>"

    if ((i == null) || (i >= el.options.length))
        i = el.options.length-1;
    el.options[i].insertAdjacentHTML("AfterEnd", html);
}
    
function initSized(el) {
    var h = 0;
    el.children[0].style.display = "none";
    dropdown = el.children[1];
    dropdown.style.visibility = "visible";

    if (dropdown.children.length > el.size) {
        dropdown.style.overflow = "auto";
        for (var i=0; i<el.size; i++) {
            h += dropdown.children[i].offsetHeight;
        }

        if (dropdown.style.borderWidth != null) {
            dropdown.style.pixelHeight = h + 4;
        }

        else
            dropdown.style.height = h;
    }

    dropdown.style.border = sizedBorderCss;
    el.style.height = dropdown.style.pixelHeight;
}

function copySelected(el) {
    var selectedIndex = findSelected(el);
    selectedCell = el.children[0].rows[0].cells[0];
    selectedDiv  =     el.children[1].children[selectedIndex];
    selectedCell.innerHTML = selectedDiv.outerHTML;
}

function findSelected(el) {
    var selected = null;


    ec = el.children[1].children;
    var ecl = ec.length;
    
    for (var i=0; i<ecl; i++) {
        if (ec[i].getAttribute("selected") != null) {
            if (selected == null) {
                selected = i;
            }
            else
                ec[i].removeAttribute("selected");
        }
    }
    if (selected == null)
        selected = 0;

    return selected;
}

function toggleDropDown(el) {
    if (el.size == 1) {
        dropDown = el.children[1];
        
        if (dropDown.style.visibility == "")
            dropDown.style.visibility = "hidden";
            
        if (dropDown.style.visibility == "hidden")
            showDropDown(dropDown);
        else
            hideDropDown(dropDown);
    }
}

function optionClick() {
    el = getReal(window.event.srcElement, "className", "option");

    if (el.className == "option") {
        dropdown  = el.parentElement;
        selectBox = dropdown.parentElement;
        oldSelected = dropdown.children[findSelected(selectBox)]

        if(oldSelected != el) {
            oldSelected.removeAttribute("selected");
            el.setAttribute("selected", 1);
            selectBox.selectedIndex = findSelected(selectBox);
        }

        if (selectBox.onchange != null) {
            if (selectBox.id != "") {
                eval(selectBox.onchange.replace(/this/g, selectBox.id));
            }
            else {
                globalSelect = selectBox;
                eval(selectBox.onchange.replace(/this/g, "globalSelect"));
            }
        }

        if (el.backupCss != null)
        el.style.cssText = el.backupCss;
        copySelected(selectBox);
        toggleDropDown(selectBox);
        highlightSelected(selectBox, true);
    }
}

function optionOver() {
    var toEl = getReal(window.event.toElement, "className", "option");
    var fromEl = getReal(window.event.fromElement, "className", "option");
    if (toEl == fromEl) return;
    var el = toEl;
    if (el.className == "option") {
        if (el.backupCss == null)
            el.backupCss = el.style.cssText;
        highlightSelected(el.parentElement.parentElement, false);
        el.style.cssText = el.backupCss + "; " + overOptionCss;
        this.highlighted = true;
    }
}

function optionOut() {
    var toEl = getReal(window.event.toElement, "className", "option");
    var fromEl = getReal(window.event.fromElement, "className", "option");
    if (fromEl == fromEl.parentElement.children[findSelected(fromEl.parentElement.parentElement)]) {
        if (toEl == null)
            return;
        if (toEl.className != "option")
            return;
    }
    
    if (toEl != null) {
        if (toEl.className != "option") {
            if (fromEl.className == "option")
                highlightSelected(fromEl.parentElement.parentElement, true);
        }
    }
    
    if (toEl == fromEl) return;
    var el = fromEl;

    if (el.className == "option") {
        if (el.backupCss != null)
            el.style.cssText = el.backupCss;
    }

}

function highlightSelected(el,add) {
    var selectedIndex = findSelected(el);
    selected = el.children[1].children[selectedIndex];
    
    if (add) {
        if (selected.backupCss == null)
            selected.backupCss = selected.style.cssText;
        selected.style.cssText = selected.backupCss + "; " + overOptionCss;
    }
    else if (!add) {
        if (selected.backupCss != null)
            selected.style.cssText = selected.backupCss;
    }
}

function hideShownDropDowns() {
var el = getReal(window.event.srcElement, "className", "select");
var spans = document.all.tags("SPAN");
var selects = new Array();
var index = 0;
    
    for (var i=0; i<spans.length; i++) {
if ((spans[i].className == "select") && (spans[i] != el)) {
    ropdown = spans[i].children[1];
if ((spans[i].size == 1) && (dropdown.style.visibility == "visible"))
    selects[index++] = dropdown;
    }
}
for (var j=0; j<selects.length; j++) {
hideDropDown(selects[j]);
}
}

function hideDropDown(el) {
    if (typeof(fade) == "function")
    fade(el, false);
    else
    el.style.visibility = "hidden";
}

function showDropDown(el) {
    if (typeof(fade) == "function")
    fade(el, true);
    else if (typeof(swipe) == "function")
    swipe(el, 2);
    else
    el.style.visibility = "visible";
}

function initSelectBoxes() {
var spans = document.all.tags("SPAN");
var selects = new Array();
var index = 0;

for (var i=0; i<spans.length; i++) {
if (spans[i].className == "select")
selects[index++] = spans[i];
}
for (var j=0; j<selects.length; j++) {
initSelectBox(selects[j]);
}    
}

function getReal(el, type, value) {
temp = el;
while ((temp != null) && (temp.tagName != "BODY")) {
if (eval("temp." + type) == value) {
el = temp;
return el;
}
temp = temp.parentElement;
}
return el;
}
if (ie4) {
window.onload = initSelectBoxes;
document.onclick = hideShownDropDowns;
}
function writeSelectBox(matrix, id, size, onchange, css) {
    var d = window.document;
    var ie4 = (document.all != null);
    if (ie4) {
//alert("Before!");
var s = createIEString(matrix, id, size, onchange, css);
document.write(s);
//alert("After!");
}else 
{
document.write(createXString(matrix, id, size, onchange, css));}
}

function createIEString(matrix, id, size, onchange, css) {
    var str = "";
        str += '<span class="select"';
        if (size == null)
            size = 1;
        str += ' size="' + size + '"';    
        if (id != null)
            str += ' id="' + id + '"';
        if (onchange != null)
            str += ' onchange="' + onchange + '"';
        if (css != null)
        str += ' style="' + css + '"';
        str += '>\n';
        str += '<table class="selectTable" cellspacing="0" cellpadding="0"\n';
        str += ' onclick="toggleDropDown(this.parentElement)">\n';
        str += '<tr>\n';
        str += '<td class="selected"> </td>\n';
        str += '<td align="CENTER" valign="MIDDLE" class="Button"\n';
        str += ' onmousedown="this.style.border=\'2 inset buttonhighlight\'"\n';
        str += ' onmouseup="this.style.border=\'2 outset buttonhighlight\'">\n';
        str += '<span style="position: relative; left: 0; top: -2; width: 100%;">6</span></td>\n';
        str += '</tr>\n';
        str += '</table>\n';
        str += '<p class="dropDown" onclick="optionClick()" onmouseover="optionOver()" onmouseout="optionOut()">\n';
        
        for (var i=0; i<matrix.length; i++) {
            html     = matrix[i].html;
            value    = matrix[i].value;
            css      = matrix[i].css;
            selected = matrix[i].selected;
            str += '<p class="option"';
            if (value != null)
                str += ' value="' + value + '"';
            if (css != null)
                str += ' style="' + css + '"';
            if (selected != null)
                str += ' selected';
            str += '>\n';
            str += html;
            str += '</p>\n';
        }
        str += '</p>\n';
        str += '</span>\n';
    return str;
}

function createXString(matrix, id, size, onchange, css) {
var str = '<form>\n';
str += '<select';
if (size == null)
    size = 1;
str += ' size="' + size + '"';    
if (id != null)
    str += ' id="' + id + '"';
if (onchange != null)
    str += ' onchange="' + onchange + '"';
str += '>\n';

for (var i=0; i<matrix.length; i++) {
    html     = matrix[i].html;
    value    = matrix[i].value;
    css      = matrix[i].css;
    selected = matrix[i].selected;
    str += '\n<option';
    if (value != null)
    str += ' value="' + value + '"';
    if (selected != null)
        str += ' selected';
    str += '>';
    str += stripTags(html);
    str += '</option>\n';
    }
    str += '\n</select>\n';
    str += '</form>\n';
return str;
}

function stripTags(str) {
    var s = 0;
    var e = -1;
    var r = "";
    s = str.indexOf("<",e);    
    do {
        r += str.substring(e + 1,s);
        e = str.indexOf(">",s);
        s = str.indexOf("<",e);
    }
    while ((s != -1) && (e != -1))
    r += str.substring(e + 1,str.length);
    return r;
}

function Option(html, value, css, selected) {
    this.html = html;
    this.value = value;
    this.css = css;
    this.selected = selected;
}
</script>
<script type="text/javascript">
var optionArray = new Array();
optionArray[0] = new Option("Item 1", "value 1", "color: blue; text-decoration: underline;");
optionArray[1] = new Option("Item <b>2</b>", "value 2");
optionArray[2] = new Option("Item 3", "value 3", "color: red;", "selected");
optionArray[3] = new Option("Item 4", "value 4");
optionArray[4] = new Option("Item 5", "value 5");
writeSelectBox(optionArray, "select1", 1, "alert(this.options[this.selectedIndex].value)", "margin-left: 10;");
</script>
<br>
<script type="text/javascript">
writeSelectBox(optionArray, "select3", 3, "alert(this.options[this.selectedIndex].value)", "margin-left: 10;");
</script>












<br><br><br><br>
<select onchange="if(this.options[this.selectedIndex].value!=''){location=this.options[this.selectedIndex].value;}" >
<option value="http://www.163.com">网易</option>
<option value="http://www.google.com">google</option>
<option value="http://wwwsohu.com">搜狐</option>
</select>


<br><br><br><br>
<form>
<select size="1" name="D1" onchange=if(s=document.getElementById("S1")){s.style.backgroundColor=value}>
<option selected value="white">请选择颜色</option>
<option value="red">红色</option>
<option value="blue">蓝色</option>
<option value="green">绿色</option>
</select>
<br>
<textarea rows="20" name="S1" cols="35"></textarea>

</form>

<br><br>
<script language="Javascript">
var mmenus    = new Array();
var misShow   = new Boolean(); 
misShow=false;
var misdown   = new Boolean();
misdown=false;
var musestatus=false;
var mpopTimer = 0;
mmenucolor='#396DA5';mfontcolor='#80FFFF';mmenuoutcolor='#396DA5';mmenuincolor='#9595FF';mmenuoutbordercolor='#00FFFF';mmenuinbordercolor='#000000';mmidoutcolor='#269DC3';mmidincolor='#26486E';mmenuovercolor='#FFFF00';mitemedge='1';msubedge='0';mmenuunitwidth=60;mmenuitemwidth=160;mmenuheight=30;mmenuwidth='300';mmenuadjust=0;mmenuadjustV=0;mfonts='font-family: Verdana; font-size: 8pt; color: #80FFFF; ';mcursor='default';
var swipeSteps = 4;
var swipemsec = 25;
var swipeArray = new Array();
function swipe(el, dir, steps, msec) {
	if (steps == null) steps = swipeSteps;
	if (msec == null) msec = swipemsec;
	if (el.swipeIndex == null)
		el.swipeIndex = swipeArray.length;
	if (el.swipeTimer != null)
		window.clearTimeout(el.swipeTimer);
	swipeArray[el.swipeIndex] = el;
	el.style.clip = "rect(-99999, 99999, 99999, -99999)";
	if (el.swipeCounter == null || el.swipeCounter == 0) {
		el.orgLeft  = el.offsetLeft;
		el.orgTop  = el.offsetTop;
		el.orgWidth = el.offsetWidth;
		el.orgHeight  = el.offsetHeight;
	}
	el.swipeCounter = steps;
	el.style.clip = "rect(0,0,0,0)";
	window.setTimeout("repeat(" + dir + "," + el.swipeIndex + "," + steps + "," + msec + ")", msec);
}
function repeat(dir, index, steps, msec) {
	el = swipeArray[index];
	var left   = el.orgLeft;
	var top    = el.orgTop;
	var width  = el.orgWidth;
	var height = el.orgHeight;
	if (el.swipeCounter == 0) {
		el.style.clip = "rect(-99999, 99999, 99999, -99999)";
		return;
	}
	else {
		el.swipeCounter--;
		el.style.visibility = "visible";
		switch (dir) {
			case 2:
				el.style.clip = "rect(" + height*el.swipeCounter/steps + "," + width + "," + height + "," + 0 + ")";
				el.style.top  = top - height*el.swipeCounter/steps;
				break;
			case 8:
				el.style.clip = "rect(" + 0 + "," + width + "," + height*(steps-el.swipeCounter)/steps + "," + 0 + ")";
				el.style.top  = top + height*el.swipeCounter/steps;
				break;
			case 6:
				el.style.clip = "rect(" + 0 + "," + width + "," + height + "," + width*(el.swipeCounter)/steps + ")";
				el.style.left  = left - width*el.swipeCounter/steps;
				break;
			case 4:
				el.style.clip = "rect(" + 0 + "," + width*(swipeSteps - el.swipeCounter)/steps + "," + height + "," + 0 + ")";
				el.style.left  = left + width*el.swipeCounter/steps;
				break;
		}
		
		el.swipeTimer = window.setTimeout("repeat(" + dir + "," + index + "," + steps + "," + msec + ")", msec);
	}
}
var mtmpleft="";
var mtmptop="";
function hideSwipe(el) {
	window.clearTimeout(el.swipeTimer);
	el.style.visibility = "hidden";
	el.style.clip = "rect(-99999, 99999, 99999, -99999)";
	el.swipeCounter = 0;
	if(mtmpleft!="")el.style.left = mtmpleft;
	if(mtmptop!="")el.style.top = mtmptop;
}

function stoperror(){
return true;
}
window.onerror=stoperror;
function mpopOut() {
mpopTimer = setTimeout('mallhide()', 500);
}
function getReal(el, type, value) {
	temp = el;
	while ((temp != null) && (temp.tagName != "BODY")) {
		if (eval("temp." + type) == value) {
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}


function mMenuRegister(menu) 
{
  mmenus[mmenus.length] = menu
  return (mmenus.length - 1)
}
function mMenuItem(caption,command,target,isline,statustxt,img,sizex,sizey,pos){
	this.caption=caption;
	this.command=command;
	this.target=target;
	this.isline=isline;
	this.statustxt=statustxt;
	this.img=img;
	this.sizex=sizex;
	this.sizey=sizey;
	this.pos=pos;
}
function mMenu(caption,command,target,img,sizex,sizey,pos){
	this.items = new Array();
	this.caption=caption;
	this.command=command;
	this.target=target;
	this.img=img;
	this.sizex=sizex;
	this.sizey=sizey;
	this.pos=pos;
	this.id=mMenuRegister(this);
}
function mMenuAddItem(item)
{
  this.items[this.items.length] = item
  item.parent = this.id;
  this.children=true;
}

mMenu.prototype.addItem = mMenuAddItem;
function mtoout(src){

src.style.borderLeftColor=mmenuoutbordercolor;
src.style.borderRightColor=mmenuinbordercolor;
src.style.borderTopColor=mmenuoutbordercolor;
src.style.borderBottomColor=mmenuinbordercolor;
src.style.backgroundColor=mmenuoutcolor;
src.style.color=mmenuovercolor;
}
function mtoin(src){

src.style.borderLeftColor=mmenuinbordercolor;
src.style.borderRightColor=mmenuoutbordercolor;
src.style.borderTopColor=mmenuinbordercolor;
src.style.borderBottomColor=mmenuoutbordercolor;
src.style.backgroundColor=mmenuincolor;
src.style.color=mmenuovercolor;
}
function mnochange(src){
src.style.borderLeftColor=mmenucolor;
src.style.borderRightColor=mmenucolor;
src.style.borderTopColor=mmenucolor;
src.style.borderBottomColor=mmenucolor;
src.style.backgroundColor='';
src.style.color=mfontcolor;

}
function mallhide(){
	for(var nummenu=0;nummenu<mmenus.length;nummenu++){
		var themenu=document.all['mMenu'+nummenu]
		var themenup=document.all['mmenup'+nummenu]
                mnochange(themenu);
                mmenuhide(themenup);
                }
}
function mmenuhide(menuid){

hideSwipe(menuid);
misShow=false;
}
function mmenushow(menuid,pid){

menuid.style.left=mmenutable.offsetLeft+pid.offsetLeft+mmenuadjust;menuid.style.top=mmenutable.offsetTop-menuid.offsetHeight+mmenuadjustV;
if(mmenuitemwidth+parseInt(menuid.style.left)>document.body.clientWidth+document.body.scrollLeft)
menuid.style.left=document.body.clientWidth+document.body.scrollLeft-mmenuitemwidth;
mtmpleft=menuid.style.left;mtmptop=menuid.style.top;swipe(menuid,8,4);
misShow=true;
}
function mmenu_over(menuid,x){
toel = getReal(window.event.toElement, "className", "coolButton");
fromel = getReal(window.event.fromElement, "className", "coolButton");
if (toel == fromel) return;
if(x==4){
  misShow = false;
  mallhide();
  mtoout(eval("mMenu"+x));
}else{
if(!misShow){mtoout(eval("mMenu"+x));}else{
  mallhide();
  mtoin(eval("mMenu"+x));
  mmenushow(menuid,eval("mMenu"+x));
}
}

}
function mmenu_out(x){
toel = getReal(window.event.toElement, "className", "coolButton");
fromel = getReal(window.event.fromElement, "className", "coolButton");
if (toel == fromel) return;
if (misShow){
mtoin(eval("mMenu"+x));
}else{
mnochange(eval("mMenu"+x));
}

}
function mmenu_down(menuid,x){
  if(misShow){
  mmenuhide(menuid);
  mtoout(eval("mMenu"+x));
  }
  else{
  mtoin(eval("mMenu"+x));
  mmenushow(menuid,eval("mMenu"+x));
  misdown=true;
  }
}
function mmenu_up(){
  misdown=false;
}
function mmenuitem_over(x,i){
srcel = getReal(window.event.srcElement, "className", "coolButton");
if(misdown){
	mtoin(srcel);
}
else{
mtoout(srcel);
}
mthestatus = mmenus[x].items[i].statustxt;
if(mthestatus!=""){
	musestatus=true;
	window.status=mthestatus;
}

}
function mmenuitem_out(){
srcel = getReal(window.event.srcElement, "className", "coolButton");
mnochange(srcel);
if(musestatus)window.status="";

}
function mmenuitem_down(){
srcel = getReal(window.event.srcElement, "className", "coolButton");
mtoin(srcel)
misdown=true;
}
function mmenuitem_up(){
srcel = getReal(window.event.srcElement, "className", "coolButton");
mtoout(srcel)
misdown=false;
}
function mexec2(x){
var cmd;
if(mmenus[x].target=="blank"){
  cmd = "window.open('"+mmenus[x].command+"')";
}else{
  cmd = mmenus[x].target+".location=\""+mmenus[x].command+"\"";
}
eval(cmd);
}
function mexec(x,i){
var cmd;
if(mmenus[x].items[i].target=="blank"){
  cmd = "window.open('"+mmenus[x].items[i].command+"')";
}else{
  cmd = mmenus[x].items[i].target+".location=\""+mmenus[x].items[i].command+"\"";
}
eval(cmd);
}
function mbody_click(){

if (misShow){
	srcel = getReal(window.event.srcElement, "className", "coolButton");
	for(var x=0;x<=mmenus.length;x++){
		if(srcel.id=="mMenu"+x)
		return;
	}
	mallhide();
}
}
document.onclick=mbody_click;
function mwritetodocument(){
      var mwb=1;
                     var stringx='<table  id=mmenutable border=0 cellpadding=3 cellspacing=2 width='+mmenuwidth+' height='+mmenuheight+' bgcolor='+mmenucolor+
                     ' onselectstart="event.returnValue=false"'+
                     ' style="position:absolute;cursor:'+mcursor+';'+mfonts+
                     ' border-left: '+mwb+'px solid '+mmenuoutbordercolor+';'+
                     ' border-right: '+mwb+'px solid '+mmenuinbordercolor+'; '+
                     'border-top: '+mwb+'px solid '+mmenuoutbordercolor+'; '+
                     'border-bottom: '+mwb+'px solid '+mmenuinbordercolor+'; padding:0px"><tr>'
                     for(var x=0;x<mmenus.length;x++){
                     	var thismenu=mmenus[x];
                     	var imgsize="";
                     	if(thismenu.sizex!="0"||thismenu.sizey!="0")imgsize=" width="+thismenu.sizex+" height="+thismenu.sizey;
                     	var ifspace="";
                     	if(thismenu.caption!="")ifspace="&nbsp;";
                     	stringx += "<td nowrap class=coolButton id=mMenu"+x+" style='border: "+mitemedge+"px solid "+mmenucolor+
                     	"' width="+mmenuunitwidth+"px onmouseover=mmenu_over(mmenup"+x+
                     	","+x+") onmouseout=mmenu_out("+x+
                     	") onmousedown=mmenu_down(mmenup"+x+","+x+")";
                     	      if(thismenu.command!=""){
                     	          stringx += " onmouseup=mmenu_up();mexec2("+x+");";
                     	      }else{
                     	      	  stringx += " onmouseup=mmenu_up()";
                     	      }
                     	      if(thismenu.pos=="0"){
                     	          stringx += " align=center><img align=absmiddle src='"+thismenu.img+"'"+imgsize+">"+ifspace+thismenu.caption+"</td>";	
                     	      }else if(thismenu.pos=="1"){
                     	          stringx += " align=center>"+thismenu.caption+ifspace+"<img align=absmiddle src='"+thismenu.img+"'"+imgsize+"></td>";	
                     	      }else if(thismenu.pos=="2"){
                     	          stringx += " align=center background='"+thismenu.img+"'>&nbsp;"+thismenu.caption+"&nbsp;</td>";	
                     	      }else{
                     	          stringx += " align=center>&nbsp;"+thismenu.caption+"&nbsp;</td>";
                     	      }
                     	stringx += "";
                     }
                     stringx+="<td width=*>&nbsp;</td></tr></table>";
                     
                     
                     for(var x=0;x<mmenus.length;x++){
                     	thismenu=mmenus[x];
                        if(x==4){
                        stringx+='<p id=mmenup'+x+' style="visiable:none"></p>';
                        }else{
                        stringx+='<p id=mmenup'+x+
                        ' style="cursor:'+mcursor+';position:absolute;'+
                        'width:'+mmenuitemwidth+'px; z-index:'+(x+100);
                        if(mmenuinbordercolor!=mmenuoutbordercolor&&msubedge=="0"){
                        stringx+=';border-left: 1px solid '+mmidoutcolor+
                        ';border-top: 1px solid '+mmidoutcolor;}
                        stringx+=';border-right: 1px solid '+mmenuinbordercolor+
                        ';border-bottom: 1px solid '+mmenuinbordercolor+';visibility:hidden" onselectstart="event.returnValue=false">\n'+
                     	'<table  width="100%" border="0" height="100%" align="center" cellpadding="0" cellspacing="2" '+
                     	'style="'+mfonts+' border-left: 1px solid '+mmenuoutbordercolor;
                        if(mmenuinbordercolor!=mmenuoutbordercolor&&msubedge=="0"){
                     	stringx+=';border-right: 1px solid '+mmidincolor+
                     	';border-bottom: 1px solid '+mmidincolor;}
                     	stringx+=';border-top: 1px solid '+mmenuoutbordercolor+
                     	';padding: 4px" bgcolor='+mmenucolor+'>\n'
                     	for(var i=0;i<thismenu.items.length;i++){
                     		var thismenuitem=thismenu.items[i];
                     		var imgsize="";
                     	        if(thismenuitem.sizex!="0"||thismenuitem.sizey!="0")imgsize=" width="+thismenuitem.sizex+" height="+thismenuitem.sizey;
                     	        var ifspace="";
                     	        if(thismenu.caption!="")ifspace="&nbsp;";
                     		if(!thismenuitem.isline){
                     		stringx += "<tr><td class=coolButton style='border: "+mitemedge+"px solid "+mmenucolor+
                     		"' width=100% height=15px onmouseover=\"mmenuitem_over("+x+","+i+
                     		");\" onmouseout=mmenuitem_out() onmousedown=mmenuitem_down() onmouseup=";
 				stringx += "mmenuitem_up();mexec("+x+","+i+"); ";
 				if(thismenuitem.pos=="0"){
                     	            stringx += "><img align=absmiddle src='"+thismenuitem.img+"'"+imgsize+">"+ifspace+thismenuitem.caption+"</td></tr>";	
                     	          }else if(thismenuitem.pos=="1"){
                     	            stringx += ">"+thismenuitem.caption+ifspace+"<img align=absmiddle src='"+thismenuitem.img+"'"+imgsize+"></td></tr>";	
                     	          }else if(thismenuitem.pos=="2"){
                     	            stringx += "background='"+thismenuitem.img+"'>"+thismenuitem.caption+"</td></tr>";	
                     	          }else{
                     	            stringx += ">"+thismenuitem.caption+"</td></tr>";
                     	          }
 				}else{
                     		stringx+='<tr><td height="1" background="hr.gif" onmousemove="clearTimeout(mpopTimer);"><img height="1" width="1" src="none.gif" border="0"></td></tr>\n';
                     		}
                     	}stringx+='</table>\n</p>'
                     	}
                     	
                }
                
                     document.write("<p align='left'>"+stringx+"</p>");
}
function mcheckLocation(){
if(isNaN(mmenuwidth))mmenuwidth=document.body.clientWidth*parseInt(mmenuwidth.substring(0,3))/100;ym=eval(document.body.scrollTop)+document.body.clientHeight-mmenuheight-10;xm=eval(document.body.scrollLeft)+10;y=mmenutable.style.pixelTop;x=mmenutable.style.pixelLeft;if(Math.abs(ym-y)>1)mmenutable.style.pixelTop=y+=(ym-y)/5;else mmenutable.style.pixelTop=y=ym;if(Math.abs(xm-x)>1)mmenutable.style.pixelLeft=x+=(xm-x)/5;else mmenutable.style.pixelLeft=x=xm;setTimeout("mcheckLocation()",10);}

mpmenu1=new mMenu('File','','self','','','','');
mpmenu1.addItem(new mMenuItem('New','javascript:alert(\\"New\\")','self',false,'New','','','',''));
mpmenu1.addItem(new mMenuItem('Open','javascript:alert(\\"Open\\")','self',false,'Open','','','',''));
mpmenu1.addItem(new mMenuItem('Save','javascript:alert(\\"Save\\")','self',false,'Save','','','',''));
mpmenu1.addItem(new mMenuItem(null,null,null,true));
mpmenu1.addItem(new mMenuItem('Exit','javascript:alert(\\"Exit\\")','self',false,'Exit','','','',''));
mpmenu2=new mMenu('Edit','','self','','','','');
mpmenu2.addItem(new mMenuItem('Undo','javascript:alert(\\"Undo\\")','self',false,'Undo','','','',''));
mpmenu2.addItem(new mMenuItem('Forward','javascript:alert(\\"Forward\\")','self',false,'Forward','','','',''));
mpmenu2.addItem(new mMenuItem(null,null,null,true));
mpmenu2.addItem(new mMenuItem('Copy','javascript:alert(\\"Copy\\")','self',false,'Copy','','','',''));
mpmenu2.addItem(new mMenuItem('Paste','javascript:alert(\\"Paste\\")','self',false,'Paste','','','',''));
mpmenu3=new mMenu('Favorites','','self','','','','');
mpmenu3.addItem(new mMenuItem('My&nbsp;Homepage','http://www.KnifeSoft.com','blank',false,'Visit My Homepage','','','',''));
mpmenu3.addItem(new mMenuItem('Yahoo','http://www.yahoo.com','blank',false,'Visit Yahoo','','','',''));
mpmenu4=new mMenu('Help','','self','','','','');
mpmenu4.addItem(new mMenuItem('Contect','javascript:alert(\\"Contect\\")','self',false,'Contect','','','',''));
mpmenu4.addItem(new mMenuItem('Send&nbsp;me&nbsp;an&nbsp;email','mailto:support@knifesoft.com','self',false,'Send me an email.','','','',''));
mpmenu4.addItem(new mMenuItem(null,null,null,true));
mpmenu4.addItem(new mMenuItem('About','javascript:alert(\\"About\\")','self',false,'About WebMenuShop','','','',''));
mpmenu4=new mMenu('KnifeSoft','http://www.knifesoft.com','self','','','','');
mwritetodocument();
mcheckLocation();
</script>





















<br><br><br><br><br><br><br><br><br><br><br><br><br>
<SELECT onchange="window.open(this.value,'','')"> <OPTION>产品快速导航</OPTION> <OPTION style="BACKGROUND: #999; COLOR: #fff" value=03product/pro2.jsp?cateID=1&amp;CateId=1 selected>多媒体产品</OPTION> <OPTION value=http://www.tcl.com/03product/tv/chanpin-hid.htm>&nbsp;&nbsp;DLP数字光显背投</OPTION> <OPTION value=http://www.tclking.com>&nbsp;&nbsp;LCD液晶电视</OPTION> <OPTION value=http://www.tcl.com/03product/tv/chanpin-hid.htm>&nbsp;&nbsp;数字高清背投</OPTION> <OPTION value=http://www.tcl.com/03product/tv/chanpin-pdp.htm>&nbsp;&nbsp;PDP等离子电视</OPTION> <OPTION value=http://www.tcl.com/03product/tv/chanpin-crt.htm>&nbsp;&nbsp;CRT高清彩电</OPTION> <OPTION value=03product/pro2.jsp?cateID=1&amp;CateId=61>&nbsp;&nbsp;酒店电视</OPTION> <OPTION value=03product/pro2.jsp?cateID=1&amp;CateId=141>&nbsp;&nbsp;乐华彩电</OPTION> <OPTION value=http://av.tcl.com/03products/List.asp?ListID=246>&nbsp;&nbsp;视盘机</OPTION> <OPTION value=http://www.tcl.com/03product/mon/index.html>&nbsp;&nbsp;监视器</OPTION> <OPTION value=http://www.tcl.com/03product/vw/index.html>&nbsp;&nbsp;电视墙</OPTION> <OPTION style="BACKGROUND: #999; COLOR: #fff" value=03product/pro2.jsp?cateID=11&amp;CateId=1>通讯产品</OPTION> <OPTION value=http://www.tclmobile.com.cn/mobile/product.jsp?catid=77>&nbsp;&nbsp;手机</OPTION> <OPTION value=03product/pro2.jsp?cateID=11&amp;CateId=18>&nbsp;&nbsp;电话机</OPTION> <OPTION value=03product/pro2.jsp?cateID=11&amp;CateId=19>&nbsp;&nbsp;网络设备</OPTION> <OPTION value=03product/pro2.jsp?cateID=11&amp;CateId=293>&nbsp;&nbsp;宽带产品</OPTION> <OPTION style="BACKGROUND: #999; COLOR: #fff" value=03product/pro2.jsp?cateID=12&amp;CateId=1>数码产品</OPTION> <OPTION value=http://www.tcl-digital.com/product/family.asp>&nbsp;&nbsp;家用电脑</OPTION> <OPTION value=http://www.tcl-digital.com/product/business.asp>&nbsp;&nbsp;商用电脑</OPTION> <OPTION value=http://www.tcl-digital.com/product/notebook.asp>&nbsp;&nbsp;笔记本电脑</OPTION> <OPTION value=http://www.tcl-digital.com/product/digital.asp>&nbsp;&nbsp;DV产品</OPTION> <OPTION value=http://www.tcl-digital.com/product/digital.asp?Cateid=82>&nbsp;&nbsp;MP3播放器</OPTION> <OPTION value=http://www.go-video.com.cn/html/productshow.asp?sortid=25&amp;sortid2=7>&nbsp;&nbsp;MP4播放器</OPTION> <OPTION style="BACKGROUND: #999; COLOR: #fff" value=03product/pro2.jsp?cateID=13&amp;CateId=1>家电产品</OPTION> <OPTION value=03product/pro2.jsp?cateID=13&amp;CateId=25>&nbsp;&nbsp;电冰箱</OPTION> <OPTION value=03product/pro2.jsp?cateID=13&amp;CateId=26>&nbsp;&nbsp;洗衣机</OPTION> <OPTION value=http://www.tclac.com/tclaccn/product/product.aspx>&nbsp;&nbsp;空调</OPTION> <OPTION value=http://www.tclac.com/tclaccn/product/productlist6.aspx>&nbsp;&nbsp;中央空调</OPTION> <OPTION value=http://www.nanhaitcl.com/product/productlist1.aspx>&nbsp;&nbsp;电饭煲</OPTION> <OPTION value=http://www.nanhaitcl.com/product/productlist2.aspx>&nbsp;&nbsp;电磁炉</OPTION> <OPTION value=http://www.nanhaitcl.com/product/productlist3.aspx>&nbsp;&nbsp;电风扇</OPTION> <OPTION value=http://www.nanhaitcl.com/product/productlist4.aspx>&nbsp;&nbsp;饮水机</OPTION> <OPTION value=http://www.nanhaitcl.com/product/productlist5.aspx>&nbsp;&nbsp;电暖器</OPTION> <OPTION value=http://www.nanhaitcl.com/product/productlist6.aspx>&nbsp;&nbsp;净水器</OPTION> <OPTION value=http://www.nanhaitcl.com/product/productlist7.aspx>&nbsp;&nbsp;烧烤炉</OPTION> <OPTION style="BACKGROUND: #999; COLOR: #fff" value=03product/pro2.jsp?cateID=14&amp;CateId=1>电气产品</OPTION> <OPTION value=http://www.tcl-elc.com/main/gb/product/index.jsp>&nbsp;&nbsp;开关插座</OPTION> <OPTION value=http://www.tcl-lighting.com/products.asp>&nbsp;&nbsp;照明产品</OPTION> <OPTION value=http://www.tclelec.com/product/product_ljfl.htm>&nbsp;&nbsp;工业电器</OPTION> <OPTION value=03product/pro2.jsp?cateID=14&amp;CateId=161>&nbsp;&nbsp;智能楼宇</OPTION> <OPTION style="BACKGROUND: #999; COLOR: #fff" value=03product/pro2.jsp?cateID=15&amp;CateId=1>部品产品</OPTION> <OPTION value=http://www.asic.com.cn/cn/product.htm>&nbsp;&nbsp;集成电路</OPTION> <OPTION value=http://www.tclrf.com/products/index.html>&nbsp;&nbsp;高频头</OPTION> <OPTION value=http://www.tclbattery.com/china/product01.asp>&nbsp;&nbsp;电池</OPTION> <OPTION style="BACKGROUND: #999; COLOR: #fff" value=03product/pro2.jsp?cateID=16&amp;CateId=1>文化产品</OPTION> <OPTION value=http://www.meikamusic.com/>&nbsp;&nbsp;美卡音像</OPTION> <OPTION value=http://www.tcl-disc.com/tp.htm>&nbsp;&nbsp;TCL光盘</OPTION></SELECT>

后来发展到其文字内容可以增、删、编、改,即可以编辑:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>EditSelect</title>
<script>
function isIE(){
a=navigator.appVersion.split(";")
b=a[1].split(" ")
return parseFloat(b[2])
}

if (isIE()<5.5) 
{
     scHTML='<p id="selectcontent" class="selectp" style="visibility:hidden;"><!--<iframe id=selframe frameborder=0 height=100%></iframe>--><p id="selecthtml" class="selectcontent">selectáD表</p></p>'
}
else
{
     scHTML='<p id="selectcontent" class="selectp" style="visibility:hidden;"><iframe id=selframe frameborder=0 height=100%></iframe><p id="selecthtml" class="selectcontent">selectáD表</p></p>'
}

document.write(scHTML)
vDiv=selectcontent
vDivHtml=selecthtml

function editselect(name,size,defaulttext,width,height,readonly){
  var combo=this;
  this.options=new Array();
  this.oj=new Array();
  this.name=name;
  this.pname=name+'_p';
  this.buttonname=name+'_button';
  this.tablename=name+'_table';
  this.htmltable=name+'_html'
  if (!height) this.height=0; else this.height=height
  if (width) this.width=width
  if (!size) size=8
  if (!defaulttext) defaulttext=""
  if (!readonly || readonly==0) {readonly="" }else {if (readonly==1) readonly="readonly style=cursor:default";this.readonly=1}
  
  esHTML='<p id='+this.pname+'>'
         +'<table id='+this.tablename+' cellpadding=0 cellspacing=0 class=select><tr><td bgcolor=#FFFFFF>'
         +'<input type=text class=selecttext size="'+size+'" name='+name+' value="'+defaulttext+'" '+readonly+'><td><button class=selectbutton id='+this.buttonname+'>6</td></tr></table>'
         +'</p>'
  document.write(esHTML)
  this.sbutton=eval("document.all."+this.buttonname)
  
  if (this.readonly==1) eval("document.all."+this.name).onclick=function(){combo.show()}  
  
  this.sbutton.onclick=function(){combo.show()}
  this.show=function(){
    pDiv=eval(combo.pname)
    pTable=eval(combo.tablename)
    var vHTML='<table id=htmltable cellspacing="0" cellpadding="2" bgcolor="#ffffff" class="selecttable" width=100%>'
    for (i=0;i<combo.options.length;i++)
      {
       vHTML+='<tr onmouseover="mo(this)" onmouseout="mu(this)" onclick="document.all.'+combo.name+'.value=this.innerText;selectcontent.style.visibility=\'hidden\';'+combo.oj[i]+'"><td nowrap>'+combo.options[i]
      }
     vHTML+="</table>"
    vDivHtml.innerHTML=vHTML
    
    vtop=pDiv.offsetTop+pDiv.offsetHeight
    vleft=pDiv.offsetLeft+2
    
    
    vParent = pDiv.offsetParent;
     while (vParent.tagName.toUpperCase() != "BODY")
 {
  vleft += vParent.offsetLeft;
  vtop += vParent.offsetTop;
  vParent = vParent.offsetParent;
 }

   var redge=document.body.clientWidth-vleft
   var bedge=document.body.clientHeight-vtop
 
   

 if (!combo.width) {vDiv.style.width=pTable.offsetWidth} else {vDiv.style.width=combo.width}
    

    if (combo.height==0)
      {
        vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
        vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
      }
      else
      {
         if (htmltable.offsetHeight>combo.height)
          {
            vDiv.style.pixelHeight=combo.height
            vDivHtml.style.pixelHeight=combo.height


            } 
           else 
           {
          
              vDiv.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
              vDivHtml.style.pixelHeight=parseInt(htmltable.offsetHeight)+2
           }
   
       }
    
    vDivHtml.scrollTop=0
    
    if (redge<vDiv.offsetWidth)
      vDiv.style.left=vleft-1-(vDiv.offsetWidth-redge)
        else
      vDiv.style.left=vleft-1
      

   if (bedge<vDiv.offsetHeight)
    //vDiv.style.top=vtop-vDiv.offsetHeight-pDiv.offsetHeight
    vDiv.style.top=vtop-vDiv.offsetHeight+bedge
         else
      vDiv.style.top=vtop
      
    
    vDivHtml.style.width=parseInt(vDiv.style.width)
      vDiv.style.visibility="visible"
  }
  
  this.add=function(text,js){
     combo.options[combo.options.length]=text
     combo.oj[combo.oj.length]=js

  }
  
  this.clearall=function(){
  combo.options=new Array()
  }

  this.about=function(){
  
 }
}


function mo(obj){
obj.style.backgroundColor="#000099"
obj.style.color="#ffffff"
}

function mu(obj){
obj.style.backgroundColor=""
obj.style.color="#000000"
}

document.onmousedown=function(){
if (vDiv.style.visibility=="visible"){
mx=event.x + document.body.scrollLeft
my=event.y + document.body.scrollTop;

x1=vDiv.offsetLeft
y1=vDiv.offsetTop

x2=vDiv.offsetLeft+vDiv.offsetWidth
y2=vDiv.offsetTop+vDiv.offsetHeight

if (mx<x1 || my<y1 || x2<mx || y2<my) 
   { 
     vDiv.style.visibility='hidden'
   }
}
}</script>


<style>
.selecttext{
border:0px
height: 16;
font-family:arial;
font-size:12px;
}
.selectbutton{
font-family:webdings;
font-size:10px;
height: 19;
width: 16; 
border:1px solid #83A5EB;
line-height:0px;
padding-bottom:3px;
background-color:#D1E0FD
}
.selecttable{
font-family:arial;
font-size:12px;
cursor:default;
}
.selectcontent
{
position: absolute;
top:0;
left:0;
overflow:auto;
border:1px solid #000000
}

.selectp
{
position: absolute; 
width:100;
overflow:hidden;
}
.select{
border-collapse: collapse;
border:1px solid #7F9DB9
}
</style>
</head>

<body bgcolor="#83A5EB" background="http://moodboy.com/puterjam/blog/attachments/month_0408/oldr_cs1.JPG">


<table border="0" width="100%">
 <tr>
  <td width="151" align="center"><font size="2">可编辑的Select</font></td>
  <td><script>
var sel1=new editselect("select1","25","可编辑的Select","");
sel1.add("这是一个可以编辑的Select")
sel1.add("支持CSS")
sel1.add("可以通过CSS,修改外形")
sel1.add("突破原来的Select诸多限制")
</script></td>
 </tr>
 <tr>
  <td width="151" align="center"><font size="2">长度可以随意修改
可以设置为只读</font></td>
  <td>
  <script>
var sel2=new editselect("select2","20","长度可以随意修改",250,82,1);
sel2.add("这是一个可以编辑的Select")
sel2.add("支持CSS")
sel2.add("可以通过CSS,修改外形")

sel2.add("作者:舜子制作")
sel2.add("MSN:puterjam@msn.com")
</script>
  </td>
 </tr>
 <tr>
  <td width="151" align="center"><font size="2">可以遮盖系统Select</font></td>
  <td>
  <script>
var sel3=new editselect("select3","25","可以遮盖系统Select","",41);
sel3.add("这是一个可以编辑的Select")
sel3.add("支持CSS")
sel3.add("可以通过CSS,修改外形")
sel3.add("突破原来的Select诸多限制")
</script>
  </td>
 </tr>
 <tr>
  <td width="151" align="right"> </td>
  <td><select><option>系统的Select</option></select> </td>
 </tr>
</table>
</body>

</html>

可编辑的select:

按回车键输入新内容,按DEL删除选中内容<br>
<body bgcolor="#fef4d9" onload="s1.focus();">
<script language="JavaScript">
<!--
function catch_keydown(sel)
{
	switch(event.keyCode)
	{
		case 13:
			//Enter;
			sel.options[sel.length] = new Option("","",false,true);
			event.returnValue = false;
			break;
		case 27:
			//Esc;
			alert("text:" + sel.options[sel.selectedIndex].text + ", value:" + sel.options[sel.selectedIndex].value + ";");
			event.returnValue = false;
			break;
		case 46:
			//Delete;
			if(confirm("删除当前选项!?"))
			{
				sel.options[sel.selectedIndex] = null;
				if(sel.length>0)
				{
					sel.options[0].selected = true;
				}
			}
			event.returnValue = false;
			break;
		case 8:
			//Back Space;
			var s = sel.options[sel.selectedIndex].text;
			sel.options[sel.selectedIndex].text = s.substr(0,s.length-1);
			event.returnValue = false;
			break;
	}
	
}
function catch_press(sel)
{
	sel.options[sel.selectedIndex].text = sel.options[sel.selectedIndex].text + String.fromCharCode(event.keyCode);
	event.returnValue = false;
}
//-->
</script>
<select name=s1 onkeydown="catch_keydown(this);" onkeypress="catch_press(this);" style="font-size:12px;"><option>---</option></select>
<SCRIPT LANGUAGE="Javascript">
function inputToSelect(text,value)
{
i=0;
while(document.all.sel.options[i])
{
   if(document.all.sel.options[i].text == text)
      return 0;
   i++;
}
var oOption = document.createElement("OPTION");
oOption.text=text;
oOption.value=value;
document.all.sel.add(oOption);
}
</SCRIPT>

<input name="inputx" value="请选择或输入相应内容" onclick="if(this.value=='请选择或输入

相应内容'){this.value='';}else{}" style="border-left:1px solid #000000;border-top:1px solid #000000;border-bottom:1px solid #000000;border-

right:0px solid #000000;width:134;height:22px;" autocomplete="off"><span 

style="width:150;overflow:hidden">
	<select id="sel" style="width:150;margin-left:-134;border:1px solid #000000;border-left:0px;height:22px;" 

onChange="inputx.value=value" onClick="inputToSelect(inputx.value,inputx.value)"> 
		<option value="111111111">111111111</option>
		<option value="汉字也可以">汉字也可以</option>
	</select> 
</span>

为了让select里有更多的图片、css修饰及其他静、动态修饰效果,而select本身优先级别太高,其修饰效果很少且不能满足上述要求,遂涌现出很多模拟的select:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<style type="text/css">
<!--
.n1 {
	border-right: 1px none #999999;
	border-top: 1px solid #999999;
	border-bottom: 1px solid #DBDBDB;
	border-left: 1px solid #999999;
	cursor: default;
	width:80px
}
.n2 {
	background: url(http://www.blueidea.com/bbs/images/oicq.gif) no-repeat center center;
	border-top: 1px solid #999999;
	border-right: 1px solid #999999;
	border-bottom: 1px solid #DBDBDB;
	border-left: 1px none;
	width: 18px;
	cursor: default;
}
.ss {
	color: #FFFFFF;
	background: #0A246A;
}
-->
</style>
<script  lanuage="JScript">
function  turnit(ss)
{

  if  (ss.style.display=="none")  
    {ss.style.display="";
	for (var i=1;i<4;i++)
{
if (eval('t'+i).innerText==text1.value)
eval('t'+i).className='ss'
else
eval('t'+i).className=''
}
}

  else
    {ss.style.display="none";   
   }
}
function sele(tid)
{
bb.style.display='none';
text1.value=tid.innerText;
}
function over(tid)
{
for (var i=1;i<4;i++)
{
eval('t'+i).className=''
}
tid.className='ss'
if(typeof(prevObj)!='undefined')
prevObj.bgColor='';
prevObj=tid;
}

function openb()
{
if (bb.style.display=='')
bb.style.display='none'
}
</script>
<style type="text/css">
<!--
table {
	font-size: 9pt;
}
-->
</style>
</head>

<body onclick=if(event.srcElement.tagName=='BODY')bb.style.display='none';>
<table width="98" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="98" nowrap>
<input name="text1" type="text" size="10" class=n1 readonly value=请选择 onclick=turnit(bb) onSelectStart=event.returnValue=false><input name="Submit" type="text" class="n2" value="" readonly onclick=turnit(bb)>
      
    </td>
  </tr>
  <tr>
    <td id=bb style=display:none><p id="Layer1" style="position:absolute; width:98px; height:100px; overflow: scroll; overflow-x:hidden; z-index: 1;" class="n1"> 
        <table width="100%" border="0" cellpadding="0" cellspacing="0" id=tb onSelectStart=event.returnValue=false>
          <tr> 
            <td  id=t1 onMouseOver =over(this)  onclick=sele(this)>选择1</td>
          </tr>
          <tr> 
            <td id=t2 onMouseOver =over(this)  onclick=sele(this)>选择2</td>
          </tr>
          <tr> 
            <td id=t3 onMouseOver =over(this)  onclick=sele(this)>选择3</td>
          </tr>
         
        </table>
      </p></td>
  </tr>
</table>
</body>
</html>
<center><sup><font face="隶书" color="blue">上标是不是这个?</font></sup><font size="6" face="华文行楷" color="red">如果要想以其他的文字作为上标该怎么做啊?</font><sub><font face="黑体" color="green"><b><i>下标是不是这个?</b></i></font></sub>
<br><br>

下面这两个已达到较高的水准(动态内容):

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>EditSelect</title>
<script>
scHTML='<p id="selectcontent" class="selectp" style="visibility:hidden;"><iframe id=selframe frameborder=0 height=100%></iframe><p id="selecthtml" class="selectcontent">select&Aacute;&ETH;±í</p></p>'
document.write(scHTML)
vDiv=selectcontent
vDivHtml=selecthtml

function editselect(name,size,defaulttext,width,height,readonly){
  var combo=this;
  this.options=new Array();
  this.name=name;
  this.pname=name+'_p';
  this.buttonname=name+'_button';
  this.tablename=name+'_table';
  this.htmltable=name+'_html'
  
  if (!height) this.height=0; else this.height=height
  if (width) this.width=width
  if (!size) size=8
  if (!defaulttext) defaulttext=""
  if (!readonly || readonly==0) {readonly="" }else {if (readonly==1) readonly="readonly style=cursor:default";this.readonly=1}
  
  esHTML='<                    

人气教程排行