是这样吧<!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=utf-8" />
<title>无标题文档</title>
</head><body>
<input type="text" onblur="fun(this.value)" /><br/>
<script type="text/javascript">
function fun(v)
{
var l = parseInt(v,10);
for(var i=0;i<l;i++)
{
var ipt = document.createElement("input");
ipt.type = "text";
document.body.appendChild(ipt);
}
}
</script>
</body>
</html>

解决方案 »

  1.   

    我的意思是在原来已经有的form中增加节点啊 !
    你这个是把节点添加到body后面了
      

  2.   

    那改成document.form1.appendChild就成了啊
      

  3.   


    <!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=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <form>
    <input type="text" onblur="fun(this.value)" /><br/>
    <script type="text/javascript">
    function fun(v)
    {
        var l = parseInt(v,10);
        for(var i=0;i<l;i++)
        {
            var ipt = document.createElement("input");
            ipt.type = "text";
            this.parentNode.appendChild(ipt);
        }
    }
    </script>
    </form>
    </body>
    </html>
      

  4.   

    是这样的效果不?
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>create New Form</title>
            <script type="text/javascript">
                function createNew(){
                    var form1 = document.getElementsByName("form1")[0];
                    var icount = document.getElementsByName("count")[0];
                    var count = icount.getAttribute("value");
                    var div1 = document.getElementById("div1");
                    var i = 0;
                    var newInput = document.createElement("input"); newInput.type = "text";
    newInput.name= "username";
    form1.appendChild(newInput);
                }
            </script>
        </head>
        <body onload="">
            <form name="form1">
                输入有多少到题:<input type="text" name="count" onblur="createNew()"/>
                <br/>
                <div id = "div1">
                在这个前面输出:<input type = "text" name = "after" />
                <br/>
                <input type="submit"/>
            </form>
        </body>
    </html>
      

  5.   

    凑个热闹
    <html><head><title>create New Form</title>
    <script type="text/javascript">
        function createNew(obj)
        {
     for(var i=0;i<obj.value;i++)
          { var  newE = document.createElement("div")
            var input = document.createElement("input")
        input.type="text"
            newE.appendChild(input);
            var oldE=obj.parentNode.nextSibling
        document.forms[0].insertBefore(newE,oldE)
    }}
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body onload="">    <form name="form1">
            
            <div>输入有多少到题:<input type="text" name="count" onblur="createNew(this)"/></div>
     
            <div><input type="submit"/></div>
            
        </form></body></html>
      

  6.   

    我试了你的代码了可以运行通过,那如果我现在有N个输入框,N未知,又该如果准确的添加新增加的输入框呢,这个时候用哪个.nextSibling就不合适了啊!
      

  7.   

    var oldE1=obj.parentNode.nextSibling.nextSibling ;
    var oldE2=document.getElementById("three") ;oldE1与oldE2有什么区别啊?
      

  8.   

    to  7 lou
    var oldE=obj.parentNode.nextSibling  主要是找提交按钮所在的div,换成标识ID的写法应该可以满足你说的要求
      

  9.   

    innerHTMl会破坏DOM结构。  建议createElement
      

  10.   

    我试了一下,没有div确实就不好使了
    但是为什么呢?var oldE=obj.parentNode.nextSibling这句话找到的不应该是name = count那个节点吗 ?
      

  11.   

    用div 只是为了换行  你以前用的是<br>
    var oldE=obj.parentNode.nextSibling找到的是    <div><input type="submit"/></div>当中的div元素
    你alert(oldE.innerHTML)看看