一个select框,旁边一个按钮,点击一下按钮,下面出现三个文本框1、2、3,假如点击第一个文本框,则把文本框里的内容显示在select框中

解决方案 »

  1.   

    jquery写的,希望对楼主有帮助。<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    </head>
    <body>
        <select id="Select1">
            <option></option>
        </select>
        <input type="button" value="按钮" />
        <div id="txt" style="display: none;">
            <input type="text" value="1" />
            <br />
            <input type="text" value="2" />
            <br />
            <input type="text" value="3" />
        </div>
    </body>
    </html>
    <script>
        $(function () {
            $("input[type='button']").bind("click", function () {
                //层显示
                $("#txt").show();
            });
            $("input[type='text']").bind("click", function () {
                $("#Select1").empty();
                $("#Select1").append(" <option value='" + $(this).val() + "'>" + $(this).val() + "</option>");
            });
        });
    </script>
      

  2.   

    <select id='s'></select>
    <input id='t' onclick='fun1(this);'></input>
    function fun1(obj){
       var ss=document.getElementById('s');
       var opt = document.createElement("<option>");
       opt.text = this.value;
       opt.name = this.id;
       ss.options.add(opt);
    }
    大概是这个意思 ,具体什么样还要看你的需求
      

  3.   

    要求用js写
    已经写了一部分
    var oSel = document.createElement("select");
    oSel.multiple = true;
    oSel.size = 3;
    oSel.style.width = "150px";
    document.body.appendChild(oSel);var button=document.createElement("input");
    button.type="button";
    button.value="Add";
    button.onclick=function(){
    add();
    }
    document.body.appendChild(button);function add(){
    var text1=document.createElement("input");
    var text2=document.createElement("input");
    var text3=document.createElement("input");
    text1.value = "tt";
    text2.value="tingting";
    text3.value="紫蔓"
    document.body.appendChild(text1);
    document.body.appendChild(text2);
    document.body.appendChild(text3);
    //text1.click = aa(text1.value);
    }还有一步就是点击任一个文本框,然后把文本框里的值显示在那个大的文本框里,帮忙!
      

  4.   


    <!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=""> </HEAD><BODY>
    <script type='text/javascript'>
    var oSel = document.createElement("select");
    oSel.multiple = true;
    oSel.size = 3;
    oSel.style.width = "150px";
    document.body.appendChild(oSel);var button=document.createElement("input");
    button.type="button";
    button.value="Add";
    button.onclick=function(){
    add();
    }
    document.body.appendChild(button);function add(){
    var text1=document.createElement("input");
    var text2=document.createElement("input");
    var text3=document.createElement("input");
    text1.value = "tt";
    text2.value="tingting";
    text3.value="紫蔓"
    document.body.appendChild(text1);
    document.body.appendChild(text2);
    document.body.appendChild(text3);
    text1.onclick = text2.onclick = text3.onclick = function(){
    var option = document.createElement('option');
    option.innerText = this.value;
    oSel.appendChild(option);
    }
    }
    </script>
    </BODY>
    </HTML>