<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript"> 
function selectjdzq() 

  document.getElementById('jdzq').value = document.getElementById('jdzq1').value; 
 // youxiaoriqi() 
} </script>  <select name="jdzq1" id="jdzq1" onChange="selectjdzq()" >
    <option value=""> </option>
    <option value="2"> 2 </option>
    <option value="3"> 3 </option>
    <option value="6"> 6 </option>
    <option value="12"> 12 </option>
    <option value="24"> 24 </option>
    <option value="36"> 36 </option>
  </select>
  <input name="jdzq" type="text" id="jdzq" onFocus="this.value='';" value="123" />
  
  
</body>
</html>这样?

解决方案 »

  1.   

    效果是这样的,但是我是想将两个控件叠加到一起,让录入的人觉得就是就是一个控件,不知道如何实现。
    <head> 
    <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312"   /> 
    <script   language="JavaScript"   > 
    function   selectjdzq() 

        document.form1.jdzq.value   =   document.form1.jdzq1.value; 
        } 
    </script> 
    </head> <body> 
    <tr>   
                <td   width="25%"   height="30"   bgcolor="#bfbfbf">   
                <div   align="center"   > 检定周期: </div>         </td> 
        <td   width="75%"   bgcolor="#efefef"   style="height:30px;position:relative"> 
        <select   name="jdzq1"     id="jdzq1"   style="position:absolute;width:80px;   clip:rect(0   80   60   60);"   onChange="selectjdzq()"   > 
                    <option   value="">   </option> 
                    <option   value="2"> 2 </option> 
                    <option   value="3"> 3 </option> 
                    <option   value="6"> 6 </option> 
                    <option   value="12"> 12 </option> 
                    <option   value="24"> 24 </option> 
                    <option   value="36"> 36 </option> 
                </select> 
        <input   name="jdzq"   type="text"     id="jdzq"   style="position:absolute;width:80px;"   onFocus="this.value='';document.form1.jdzq.value='';"   value=" <%=Session("jdzq")%> "   /> 
                </td> 
        </tr> 
    </body> 
    </html>
    我这个程序在ie6.0下,可以显示为一个控件,但是在ie7.0下,只能显示输入框,下拉框显示不出来
     
      

  2.   

    下面在ie6和ff2.0+运行没问题,你试试
    <html>
    <head>
    <title>接受输入的select</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head> <body bgcolor="#FFFFFF" text="#000000">
    <select  style="position:absolute; left: 0px;  top: 0px; width: 120px; height: 18px; clip: rect(0 120 18 100)" id="select" onchange="ReSetSelect()">
      <option value="aaaaaaaa">aaaaaaaa</option>
      <option value="bbbbbbbb">bbbbbbbb</option>
      <option value="cccccccc">cccccccc</option></select>
    <input type="text" style="position:absolute; left: 0px; top: 0px; width: 100px; height: 18px" id="textfield"/>
    <script type='text/javascript'>
    function isContain()
    {
      for(var i=0;i<select.options.length;i++)
      {
        if(select.options[i].text==textfield.value)
          return true;
      }
      return false;
    }
    function ReSetSelect()
    {
      if(textfield.value!=""&&!isContain())
      {
       var o=new Option(textfield.value,textfield.value);
       select.options.add(new Option(textfield.value,textfield.value));
       textfield.value="";
     }
     textfield.value=select.value;
     textfield.select();
    }
    </script>
    </body>
    </html>
      

  3.   

    可以参考dhcombobox
    http://www.v-ec.com/dh20156/article.asp?id=15
      

  4.   

    <span id="span_Username">
    <span style="position:relative;">
    <span style="margin-left:130px;width:50px;overflow:hidden;">
    <select id="Username_sel" style="width:150px;margin-left:-130px" onChange="this.parentNode.nextSibling.value=this.value">
            <option <?php if($_GET['Username']==""){echo "selected=\"selected\"";}else{echo "";}?> value=""><?php echo $_la['all'] ?></option>
            <?php for($j=0;$j<$UserList["ulNum"];$j++){?>
            <option title="<?php echo stripslashes(htmlspecialchars($UserList[$j]["name"])) ?><?php if($UserList[$j]['fullname']==""){echo "";}else{echo "(".stripslashes(htmlspecialchars($UserList[$j]['fullname'])).")";} ?>" <?php if($_GET['Username']==$UserList[$j]["name"]){echo "selected=\"selected\"";}else{echo "";}?> value="<?php echo stripslashes(htmlspecialchars($UserList[$j]["name"])) ?>"><?php echo stripslashes(htmlspecialchars($UserList[$j]["name"])) ?><?php if($UserList[$j]['fullname']==""){echo "";}else{echo "(".stripslashes(htmlspecialchars($UserList[$j]['fullname'])).")";} ?></option>
            <?php }?>
    </select></span><input name="Username" id="Username" onKeyUp="selectN('Username_sel');" onBlur="CheckTrim(Username)" style=" height:22px;width:130px;position:absolute;left:0px; border-bottom:1px solid #7f9db9;border-left:1px solid #7f9db9;border-top:1px solid #7f9db9; border-right:0px solid #7f9db9;" value="<?php echo stripslashes(htmlspecialchars($_GET['Username'])) ?>">
    </span>
        </span>
    呵呵,前段时间刚做出来,支持IE 6 7 和 FF  就是个CSS实现的,LZ自己改改,应该没有问题
      

  5.   

    /***Date:2007/12/18****/
    window.inpect = function(parent ,width){ //基本属性 public
    this.parent = (typeof parent == 'undefined')?document.body:parent;
    this.width =  parseInt((typeof width == 'undefined')?130:width); //获取对象方法 private
    var $ = function(el){
    return (typeof el == 'object')?el:document.getElementById(el);
    };

    //初始化控件 private
    this.init = function(){
    var strHTML = "<div style='position:absolute;z-index:1;clip:rect(3 280 20 "+ this.width +");'>"
    + "<select id='sel' style='width:"+ (this.width+17) +"'></select>"
    + "</div>"
    + "<div style='position:absolute;z-index:2;'>"
    + "<input hideValue='' id='inp' style='width:"+ (this.width+17) +"; height:20;'>"
    + "</div>";
    this.parent.innerHTML = strHTML;

    };this.init();

    //选中赋值 anonymous 
    $("sel").onchange = function(){
    $("inp").value = this.options[this.selectedIndex].text;
    $("inp").hideValue = this.value;
    };

    //添加option public
    this.addOption = function(text ,value){
    var op= new Option(text ,value);
    $("sel").options.add(op);
    }; //给控件赋值 public
    this.setValue = function(value){
    $("inp").value = selOption(value);
    $("inp").hideValue = value;
    }; //获取控件值 public
    this.getValue = function(){
    return $("inp").hideValue;
    }; //选中控件 private
    var selOption = function(value){
    if($("sel").options.length != 'undefined'){
    for(var i=0;i<$("sel").options.length;i++){
    if($("sel").options[i].value == value){
    $("sel").options[i].selected = true;
    return $("sel").options[i].text;
    }
    }
    }
    };
    };
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>可输入的下拉列表.html</title>
    <script type="text/javascript" src="inpect.js"></script>
    <script type="text/javascript">
    window.onload = function(){
    window.ipt = new window.inpect(document.all("aaa"));
    ipt.addOption("aa" ,"11");
    ipt.addOption("bb" ,"22");
    ipt.addOption("cc" ,"33");
    };</script>
    </head>
    <body> 
    <div id="aaa" style='position:absolute;z-index:1;left:200'>

    </div>
    <input type="button" value="设置" onclick="ipt.setValue('22')">
    <input type="button" value="获取" onclick="alert(ipt.getValue())">
    </body> 
    </html>