首页 > 代码库 > 可编辑的select框的实现(实用版)

可编辑的select框的实现(实用版)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
< HTML>
 < HEAD>
 < TITLE>可编辑select</TITLE>
  < script>
     function selShiftDesc(desc){
    if(desc.options.selectedIndex!=0){
    var v=desc.value;
    var t=desc.options[desc.options.selectedIndex].text 
    var i= document.getElementByIdx_x_x_x("i");
    var n= document.getElementByIdx_x_x_x("n");
    i.value=http://www.mamicode.com/t;
    n.value=http://www.mamicode.com/v;
    }
  }
  function c(){
   var t  = document.getElementByIdx_x_x_x("i").value;
   alert(t);
  }
  </script>
 < /HEAD>

 <BODY>
            < div style="position:relative;">  
               < span style="margin-left:100px;width:18px;overflow:hidden;">
             < select id =‘r‘ style="width:118px;margin-left:-100px" onchange="selShiftDesc(this);">
       < Option value=http://www.mamicode.com/-1>-请选择-
       < Option value=http://www.mamicode.com/1>n1
       < Option value=http://www.mamicode.com/2>n2
       < Option value=http://www.mamicode.com/3>n3
       < Option value=http://www.mamicode.com/4>n4
       < Option value=http://www.mamicode.com/5>n5
       < Option value=http://www.mamicode.com/6>n6
       < Option value=http://www.mamicode.com/7>n7
       < Option value=http://www.mamicode.com/8>n8
       < Option value=http://www.mamicode.com/9>n9
       < /select>
      < /span>
            < input id="i" type=‘text‘ name="newswriter.notes" style="width:100px;position:absolute;left:0px;"/>

     < /div>

      < input type=‘button‘ id="b" value=http://www.mamicode.com/‘提交‘onclick="c();"/>
 < /BODY>
< /HTML>