http://lucky.myrice.com/temp/select.htm
怎么不行??

解决方案 »

  1.   

    好的先谢过了,我要求一个组合框控件呀,你们知道,在网页里的select只能从已有选项中选择的,是吧?而我现在要求是:对有的已有选项应该是可以选,如果没有呢,也可以把这个控件当成text控件一样使用,自己输入选项
      

  2.   

    版主你提供的那个控件不能自己输入东西的,看看无为提供的吧,可惜代码是被处理过的(变量什么的全是数字!),我整理了快一天了,还是不行,你们水平高可能处理起来也会快一些:)
    帮忙看看吧,分可以再加的
    <HTML><HEAD><TITLE>Combo Box Advanced Demo</TITLE>
    <META content="text/html; charset=gb2312" http-equiv=Content-Type>
    <SCRIPT> 
    function thefunction7( x956203888512 ) 
    {
    var tmpvars = 0; 
    while ( x956203888512 != null ) 

    tmpvars += x956203888512.offsetLeft; 
    x956203888512 = x956203888512.offsetParent; 

    return tmpvars; 
    } function thefunction8( x956203888512 ) 

    var x956203888515 = 0; 
    while ( x956203888512 != null ) 

    x956203888515 += x956203888512.offsetTop; 
    x956203888512 = x956203888512.offsetParent; 

    return x956203888515; 
    } function initvars() 

    var IfIE50=true; 
    var navigatorname=navigator.appVersion; 
    var navigatorvers=parseInt(navigatorname.indexOf("MSIE")); 
    if (navigatorvers>=1) 

    var i=parseInt(navigatorname.charAt(navigatorvers+5)); 
    if (i>=5) 

    IfIE50=false; 


    if (IfIE50) 

    alert("This page may not be displayed properly:\n\ This product requires Microsoft Internet Explorer 5 or later browser only."); 

    }initvars();
    var ctrl_objects = new Array(); function ctrlclass(classtype, classname) 

    this.ctrlid = document.all[classtype]; 
    this.ctrlid.selectedIndex = -1; 
    this.thefunctionA = thefunctionA; 
    this.onchangefun = onchangefun; 
    this.Fun_onblur = Fun_onblur; 
    this.Fun_change_select_item = Fun_change_select_item; 
    this.Fun_onkeyup = Fun_onkeyup; 
    this.thefunctionD = thefunctionD; 
    this.focus = focus; 
    this.x956203888471 = false; 
    this.x956203888472 = ""; 
    var ctrlbox_text = classtype + "_text"; 
    if (document.all[ctrlbox_text] != null) 

    alert("The following id: '" + ctrlbox_text +"' is used internally by the Combo Box!\r\n"+ "Use of this id in your page may cause malfunction. Please use another id for your controls.");
     } 
     var textctrlhtml = "<INPUT type='text' id=" + ctrlbox_text + " name=" + ctrlbox_text + " onblur='" + classname + ".Fun_onblur()' " +  " style='display: none; position: absolute' value='' >";
     this.ctrlid.insertAdjacentHTML("afterEnd", textctrlhtml);   this.current_selected_id = document.all[ctrlbox_text];   var ctrlbox_value = classtype + "_value"; 
     if (document.all[ctrlbox_value] != null) 
     { 
      alert("The following id: '" + ctrlbox_value + "' is used internally by the Combo Box!\r\n"+ "Use of this id in your page may cause malfunction. Please use another id for your controls."); 
      } 
     var hiddentexthtml = "<INPUT type='hidden' "+ " id=" + ctrlbox_value + " name=" + ctrlbox_value + " >";
     this.ctrlid.insertAdjacentHTML("afterEnd", hiddentexthtml);   this.x956203888478 = document.all[ctrlbox_value];   this.show_hide = false; 
     this.thefunctionA(); 
     ctrl_objects[ctrl_objects.length] = this; 
    } function thefunctionD(x956203888482) 

    this.x956203888471 = x956203888482; 
    }  
    function Fun_onblur() 

    var object_id = this.ctrlid; 
    var old_selected_id = this.current_selected_id; 
    var x956203888495 = this.x956203888478; 
    var i; 
    x956203888495.value = old_selected_id.value; 
    object_id.selectedIndex = -1; 
    if (old_selected_id.value == "") 

    return; 

    var options_length = object_id.options.length; 
    for (i=0; i<options_length; i++) 

    var options_text = object_id.options(i).text; 
    var x956203888497 = old_selected_id.value; 
    if (this.x956203888471) 

    options_text = options_text.toUpperCase(); 
    x956203888497 = x956203888497.toUpperCase(); 

    if (options_text == x956203888497) 

    object_id.selectedIndex = i; x956203888495.value = object_id.options(i).value; 
    return; 



     
    function thefunctionA() 

    if (!this.show_hide) 

    this.show_hide = true; 
    this.current_selected_id.style.display="none"; 
    this.ctrlid.style.position="static"; 
    this.current_selected_id.style.posLeft = thefunction7(this.ctrlid); 
    this.current_selected_id.style.posTop = thefunction8(this.ctrlid) + 1; 
    this.current_selected_id.style.posWidth = this.ctrlid.offsetWidth - 16; 
    this.current_selected_id.style.posHeight = this.ctrlid.offsetHeight; 
    this.ctrlid.style.position ="absolute"; 
    this.ctrlid.style.posLeft = this.current_selected_id.style.posLeft; 
    this.ctrlid.style.posTop = this.current_selected_id.style.posTop; 
    this.x956203888500 = this.ctrlid.offsetWidth; 
    var x956203888501 = "rect(0 " + (this.ctrlid.offsetWidth) + " " + this.ctrlid.offsetHeight + " " + (this.current_selected_id.style.posWidth - 2 ) + ")"; 
    this.ctrlid.style.clip = x956203888501; 
    this.current_selected_id.style.display=""; 
    this.show_hide = false; 

    } function onchangefun() 

    var x956203888502 = this.ctrlid.selectedIndex; 
    var x956203888503 = this.ctrlid.options[x956203888502]; 
    this.current_selected_id.value = x956203888503.text; this.current_selected_id.focus(); 
    this.current_selected_id.select(); this.ctrlid.selectedIndex=-1; 
    } function Fun_change_select_item(thetext) 

    var select_length = this.ctrlid.options.length; 
    var i; 
    for (i=0; i<select_length; i++) 

    if (this.ctrlid.options(i).text == thetext) 

    this.ctrlid.selectedIndex = i; 
    this.current_selected_id.value = this.ctrlid.options(i).text; 
    this.x956203888478.value = this.ctrlid.options(i).value; 
    return; 


    this.ctrlid.selectedIndex = -1; 
    this.current_selected_id.value = ""; 
    } function Fun_onkeyup() 

    ;
    } function focus() 

    this.current_selected_id.focus(); 
    } function load3() 

    var i; 
    for (i=0; i < ctrl_objects.length; i++)

    ctrl_objects[i].thefunctionA(); 


    </SCRIPT><META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
    <BODY onload="load1(); load2(); load3();" onresize="load2(); load3(); ">
    <SCRIPT> var object1; 
    var dateComboBox; 
    function load1() 

    object1 = new ctrlclass("ComboBoxID", "object1"); 
    object1.Fun_change_select_item("[email protected]"); 
    object1.thefunctionD(true); 
    dateComboBox = new ctrlclass("dateComboBoxID", "dateComboBox"); 
    document.all.setSortCB.checked = false; 
    document.all.setDoLookupCB.checked = true; 
    document.all.setCaseInsensitiveCB.checked = true; 
    document.all.OnlyAllowedEntriesCB.checked = true; 

    function load2() 

    if (object1!=null) 

    if (tdid.offsetWidth < object1.x956203888500) 

    var x956203888446 = table4myComboBox.style.tableLayout; 
    table4myComboBox.style.tableLayout = "fixed"; 
    tdid.style.posWidth = object1.x956203888500; 
    table4myComboBox.style.tableLayout = x956203888446; 



    </SCRIPT>
    <select id=ComboBoxID onChange=object1.onchangefun(); 
          style="POSITION: absolute; left: 24px; top: 19px" name="select">
      <option selected 
            [email protected]>[email protected]</option>
      <option 
            [email protected]>[email protected]</option>
      <option 
            [email protected]>[email protected]</option>
    </select>
    </BODY>
    </HTML>
      

  3.   

    用控件可能更好些
    http://www.blueidea.com/bbs/NewsDetail.asp?id=414637