我有一个下拉菜单怎么样才能把选中项的内容 填到一个textarea里?

解决方案 »

  1.   


    <textarea id="test"></textarea>
    <select onchange='document.getElementById("test").innerHTML=this.options[this.selectedIndex].value;'>
    <option value="123">123</option>
    <option value="456">456</option>
    </select>
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
      <script type="text/javascript">
       function test()
       {
          var em=document.getElementById("select");
      var option=em.options[em.selectedIndex].text;
      document.getElementById("id").value=option;
       }
      </script>
     </HEAD> <BODY>
      <textArea  id="id" name="text">
      </textArea>
      <select id="select" onchange="test();">
          <option>1</option> 
      <option>2</option> 
      <option>3</option> 
      </select>
     </BODY>
    </HTML>
      

  3.   

    <html>
    <head>
    <title>test</title>
    <script>
    function change() {
    var sel = document.getElementById("sel");
    var area = document.getElementById("area");
    area.innerHTML += sel.value;
    }
    </script>
    </head>
    <body>
    <select id="sel" onchange="change()">
    <option value="123">123</option>
    <option value="456">456</option>
    </select>

    <textarea id="area"></textarea>
    </body>
    </html>
      

  4.   

    我的部分页面:
    <select id="sel1"> 
    <option value="123">123 </option> 
    <option value="456">456 </option> 
    </select> 
    <select id="sel"> 
    <option value="123">123 </option> 
    <option value="456">456 </option> 
    </select> 
    <select id="sel2"> 
    <option value="123">321</option> 
    <option value="456">654</option> 
    </select> 
    <select id="sel3"> 
    <option value="123">213</option> 
    <option value="456">456 </option> 
    </select> 
    我想 在选中123的时候 在sel里显示sel2的内容
    选中456的时候 在sel里显示sel3的内容
      

  5.   

    你的sel里面都没有sel2,sel3的内容,比较麻烦啊.参考下下面的代码:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <META NAME="Generator" CONTENT="EditPlus">
      <META NAME="Author" CONTENT="">
      <META NAME="Keywords" CONTENT="">
      <META NAME="Description" CONTENT="">
      <script type="text/javascript">
       function test()
       {
          var em=document.getElementById("sel");
      var em1=document.getElementById("sel1");
      var em2=document.getElementById("sel2");
      var em3=document.getElementById("sel3");   var sel=em.options[em.selectedIndex].text;
      var sel1=em1.options[em1.selectedIndex].text;
      var sel2=em2.options[em2.selectedIndex].text;
      var sel3=em3.options[em3.selectedIndex].text;   if(sel1==123)
      {
     var option=document.createElement("option");
     option.value=sel2;
             option.innerHTML=sel2;
     em.appendChild(option);
             em.options[em.selectedIndex].text=sel2;
      }
      else if(sel1==456)
      {
         var option=document.createElement("option");
     option.value=sel3;
             option.innerHTML=sel3;
     em.appendChild(option);
             em.options[em.selectedIndex].text=sel3;
      }
      
       }
      </script>
     </HEAD> <BODY>
     <select id="sel1" onchange="test();"> 
    <option value="123">123 </option> 
    <option value="456">456 </option> 
    </select> 
    <select id="sel"> 
    <option value="123">123 </option> 
    <option value="456">456 </option></select> 
    <select id="sel2"> 
    <option value="123">321 </option> 
    <option value="456">654 </option> 
    </select> 
    <select id="sel3"> 
    <option value="123">213 </option> 
    <option value="456">456 </option> 
    </select>  </BODY>
    </HTML>
      

  6.   

    这年头,想挣点分可真难。。 <textarea id="sel"> </textarea> 
    <select id="sel1" onchange='document.getElementById("sel").innerHTML=this.options[this.selectedIndex].value;'> 
    <option value="选择1">选择1 </option> 
    <option value="选择2">选择2 </option> 
    </select> <select id="sel2" onchange='document.getElementById("sel").innerHTML=this.options[this.selectedIndex].value;'> 
    <option value="选择3">选择3 </option> 
    <option value="选择4">选择4</option> 
    </select> 
    <select id="sel3" onchange='document.getElementById("sel").innerHTML=this.options[this.selectedIndex].value;'> 
    <option value="选择5">选择5 </option> 
    <option value="选择6">选择6</option> 
      

  7.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <script type="text/javascript">
    /**
     * author: develop_design_level
     * date: 2009-10-28
     * @param {Object} id
     */
    function $(id){
    if(document.getElementById){
    return document.getElementById(id);
    }else{
    return document.all.id;
    }
    }

    window.onload = function(){
    $('selId').onchange = function(){
    var str = this.options[this.selectedIndex].text;
    $('txtId').value = str;
    };
    };
    </script>
    </head>
    <body>
    <select id="selId">
    <option value="-1">===请选择===</option>
    <option value="1">==1==</option>
    <option value="2">==2==</option>
    <option value="3">==3==</option>
    <option value="4">==4==</option>
    <option value="5">==5==</option>
    </select>
    <br/>
    <textarea id="txtId"></textarea>
    </body>
    </html>-------- 结贴,给分 ----------
      

  8.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <script type="text/javascript">
    /**
     * author: develop_design_level
     * date: 2009-10-28
     * @param {Object} id
     */
    function $(id){
    if(document.getElementById){
    return document.getElementById(id);
    }else{
    return document.all.id;
    }
    }

    window.onload = function(){
    $('selId').onchange = function(){
    var str = this.options[this.selectedIndex].text;
    $('txtId').value = str;
    };
    };
    </script>
    </head>
    <body>
    <select id="selId">
    <option value="-1">===请选择===</option>
    <option value="1">==1==</option>
    <option value="2">==2==</option>
    <option value="3">==3==</option>
    <option value="4">==4==</option>
    <option value="5">==5==</option>
    </select>
    <br/>
    <textarea id="txtId"></textarea>
    </body>
    </html>