<select name="menu1" onchange="addtext(this)" > 
<option value=""> </option>  //第一个值为空哦      
<option value="1">1 </option> 
<option value="2">2 </option> 
<option value="3">2 </option> 
<input type="text" value="" size="30" name="get" id="get"> 
<script>
function addtext(o)
{
if(document.getElementById("get").value=="")document.getElementById("get").value+=o.value;
if(document.getElementById("get").value.indexOf(o.value)==-1)document.getElementById("get").value+=","+o.value
}
</script>

解决方案 »

  1.   

    <!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> 
    <style></style>
    <script>
    function change(n){
    var input = document.getElementById("i");
    if(input.value!=""){
    if(n!=""){
    var flag = false;
    var arr = input.value.split(",");
    for(var i = 0;i<arr.length;i++){
    if(arr[i] == n){
    flag = true;
    break;
    }
    }
    if(!flag){
    input.value = input.value + "," +n;
    }
    }
    }else{
    input.value = n;
    }
    }
    </script>
    </head> 
    <body>
    <select onchange="change(this.value)">
    <option value=""> </option>   
    <option value="1">1 </option>
    <option value="2">2 </option>
    <option value="3">2 </option> 
    </select>
    <input type="text" id="i" />
    </body> 
    </html>