根据你个人需求了
可以控制隐:$("").style.visibility = "hidden"
也可以生成
createElement("");
appendChild();

解决方案 »

  1.   

    <!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>
    <script type="text/javascript">
    var CreateText=function(){
    var module=document.getElementById("textmoudle");
    var a = document.createElement("input");
    a.id="num"
        a.type = "text";
        a.value = "";
    module.appendChild(a);
    };
    var DeleteText=function(){
    var module=document.getElementById("textmoudle");
    var texts=document.getElementsByTagName("num");
    module.removeChild(document.getElementsByTagName("num")[0]);
    };
    </script>
     <BODY>
     <input type="button" value="增加" onclick="CreateText()"/>
     <input type="button" value="删除" onclick="DeleteText()"/>
     <hr/>
     <div id="textmoudle">
      <input id="num" type="text" value=""/>
      </div>
     </BODY>
    </HTML>
    --------------------
    没有测试!请测试下
      

  2.   

    JS操作表格,添加删除一组文本框的行
    http://blog.chinaunix.net/u1/57965/showart_688399.html
      

  3.   

    <!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>
    <script type="text/javascript">
    var CreateText=function(){
    var module=document.getElementById("textmoudle");
    var a = document.createElement("input");
    a.id="num"
        a.type = "text";
        a.value = "";
    module.appendChild(a);
    };
    var DeleteText=function(){
    var module=document.getElementById("textmoudle");
    var texts=document.getElementsByName("num");
    //alert(texts.length);
    module.removeChild(document.getElementsByName("num")[0]);
    };
    </script>
     <BODY>
     <input type="button" value="增加" onclick="CreateText()"/>
     <input type="button" value="删除" onclick="DeleteText()"/>
     <hr/>
     <div id="textmoudle">
      <input id="num" type="text" value=""/>
        <input id="num" type="text" value=""/>
      </div>
     </BODY>
    </HTML>
    ====================
    不好意思,我测试了,有点问题!这个是修改了下!
      

  4.   


    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    <head>
    </head> 
    <script>
    var create_element = function()
    {
    var _input = document.createElement("input");
    var _button = document.createElement("input");
    var _del_button = document.createElement("input");
    _button.setAttribute("type","button");
    _button.setAttribute("value",'增加');
    _del_button.setAttribute("type","button");
    _del_button.setAttribute("value","删除");
    document.body.appendChild(_input);
    document.body.appendChild(_button);
    document.body.appendChild(_del_button);
    }

    var add_input = function()
    {
    var _input = document.createElement("input");
    _input.setAttribute("type","text");
    document.body.appendChild(_input);
    }

    var remove_input = function()
    {
    document.body.removeChild(document.body.lastChild);
    }

    window.onload = function()
    {
    create_element();
    if(document.all)
    {
    document.body.lastChild.previousSibling.attachEvent("onclick",add_input);
    document.body.lastChild.attachEvent("onclick",remove_input);
    }
    else
    {
    document.body.lastChild.previousSibling.addEventListener("click",add_input,false);
    document.body.lastChild.addEventListener("click",remove_input,false);
    }
    }
    </script>
    <body></body> 
    </html> 
      

  5.   

    <!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>
    <script type="text/javascript">
    var CreateText=function(){
    if(document.getElementsByName("num").length +1 >5)
    {
    alert("已经5个了,不能继续添加!");
    return ;
    }
    var module=document.getElementById("textmoudle");
    var a = document.createElement("input");
    a.id="num"
        a.type = "text";
        a.value = "";
    module.appendChild(a);
    };
    var DeleteText=function(){
    if(document.getElementsByName("num").length ==1)
    {
    alert("已经剩下最后一个了,不要再删除了!谢谢!");
    return ;
    }
    var module=document.getElementById("textmoudle");
    var texts=document.getElementsByName("num");
    //alert(texts.length);
    module.removeChild(document.getElementsByName("num")[0]);
    };
    </script>
     <BODY>
     <input type="button" value="增加" onclick="CreateText()"/>
     <input type="button" value="删除" onclick="DeleteText()"/>
     <hr/>
     <div id="textmoudle">
     
      </div>
     </BODY>
    </HTML>
      

  6.   

    小例子:
    <script type="text/javascript">
    var p=1;
    function pga(){p=p;return p;}
    function Up_page(){if(p<=1)p=1;else p=p-1;return p;}
    function Down_page(){if(p<5)p=p+1;return p;}
    function bbb(aa)
    {
       var obj=document.getElementById("ccc");
       var html="";
       for(i=1;i<=aa;i++)
       {
       html+="<input type='textbox' name=user+'i+1'/>"
       }
       obj.innerHTML=html;
    }
    </script> 
      </head>
      <body>
      <div id="ccc"><input type='textbox' name=user1/></div>
      <input type="button" value="添加" onclick="bbb(Down_page());"/>
      <input type="button" value="删除" onclick="bbb(Up_page());"/>
      </body>
    </html>
      

  7.   

    谢谢楼上各位!!!不过跟我的票求对不上.是我没说清楚.
    有一组输入框(三个TextBox,两个DropdownList),最少显示一组.通过增加,删除按钮来显示一组至五组输入框.最多显示五组.
      

  8.   

    我将输入框放在DIV中,做成五个DIV中,通过DIV的visible属性来控制是否显示,但是我无论是设成<div visible="true">,
    还是<div visible="false">都没有反应。请问是怎么回事?》
      

  9.   

    <div style="visibility:hidden" >111</div>
    //是style.visibility,不是div.visible
    div.style.visibility="visible";
    div.style.visibility="hidden";div.style.display="none"//隐藏
    div.style.display="block"//显示建议使用style.display,使用visibility的话会占位置
      

  10.   

    <select id="Select_P">
                <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>
           <div id="div_cjr_1">
               </div>
    <div id="div_cjr_2">
               </div>
    <div id="div_cjr_3">
               </div>
    <div id="div_cjr_4">
               </div>
    <div id="div_cjr_5">
               </div> 
    window.onload=initForm;
    window.onunload=function() {};function initForm()
    {
       document.getElementById("Select_P").selectedIndex=0;
       document.getElementById("Select_P").onchange=changnum;
    }function changnum()
    {
      var newnum=document.getElementById("Select_P");
      
      for(var i=0;i<newnum;i++)
      {
        div_cjr_[i].style.display="block";//显示
      }
      
    }
     选择列表怎么没反应呢??
      

  11.   

    <select id="Select_P">
                <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>
           <div id="div_cjr_1">1
               </div>
    <div id="div_cjr_2">2
               </div>
    <div id="div_cjr_3">3
               </div>
    <div id="div_cjr_4">4
               </div>
    <div id="div_cjr_5">5
               </div> <script>
    window.onload=initForm;
    window.onunload=function() {};function initForm()
    {
       document.getElementById("Select_P").selectedIndex=0;
      for(i=2;i<=5;i++)
      {
        document.getElementById("div_cjr_"+i).style.display="none";//隐藏2-5,因为你上面设置了只显示1个div
      }
       document.getElementById("Select_P").onchange=changnum;
    }function changnum()
    {
      var newnum=parseInt(document.getElementById("Select_P").value);
      var i,j;
      for(i=1;i<=newnum;i++)
      {
        document.getElementById("div_cjr_"+i).style.display="block";//显示
      }
      for(j=i;i<=5;i++)
      {
        document.getElementById("div_cjr_"+j).style.display="none";//隐藏
      }
    }
    </script>
      

  12.   

    div 显示style='display:none';是隐藏
        显示style='display:block';显示默认是显示