<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>无标题文档 </title> 
<script> 
function abc(){
var a = document.createElement('div');
var b = document.createElement('input');
var c = document.createElement('input');
var d = document.createElement('input');
a.appendChild(b);
a.appendChild(c);
a.appendChild(d);
document.body.appendChild(a);
}
</script> 
</head> 
<input type="button" value="button" onclick="abc()"/>
<body> 
</body> 
</html> 

解决方案 »

  1.   

    多看看手册吧Web 开发常用手册JScript语言参考.rar
    http://download.csdn.net/source/308916DHTML参考手册.rar
    http://download.csdn.net/source/308913样式表中文手册.chm
    http://download.csdn.net/source/304124
      

  2.   

    怎么设定 text的ID 和 value呢 怎么取得他们上面的值呢
      

  3.   

    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>test </title> 
    <script> 
    function test(){ 
    var a = document.createElement('div'); 
    var b = document.createElement('input'); 
    var c = document.createElement('input'); 
    var d = document.createElement('input'); 
    a.appendChild(b); 
    a.appendChild(c); 
    a.appendChild(d); 
    document.body.appendChild(a); 

    </script> 
    </head> 
    <input type="button" value="button" onclick="test()"/> 
    <body> 
    </body> 
    </html> 
      

  4.   

    <!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>
    <script>
    function crediv()
    {
    var div1=document.createElement('div'); 
      div1.style.border="1px solid #0000FF"; 
      div1.style.width = 300 + "px"; 
      div1.style.height =120 + "px"; 
      div1.innerHTML="<input type='text' value='ss1' /> <input type='text' value='ss2' /> <input type='text' value='ss3' /> ";
    document.body.appendChild(div1);
    }
    </script>
    </head><body><input type="button" onclick="crediv()" value="创建div" />
    </body>
    </html>
      

  5.   

    <!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>
    <script>
    var num=1;
    function crediv()
    {
    var div1=document.createElement('div'); 
      div1.style.border="1px solid #0000FF"; 
      div1.style.width = 300 + "px"; 
      div1.style.height =120 + "px"; 
      div1.innerHTML="<input type='text' id='s"+num+"' name='s"+num+"' value='s"+num+"' /> <input type='text' id='ss"+num+"' name='ss"+num+"' value='ss"+num+"' /> <input type='text' id='sss"+num+"' name='sss"+num+"' value='sss"+num+"' /> ";
    document.body.appendChild(div1);
    num++
    }
    </script>
    </head><body><input type="button" onclick="crediv()" value="创建div" />
    </body>
    </html>
      

  6.   

    谢谢各位了,不仅告诉了我方法,还能好心的提醒我多多学习,非常感谢。但是我还有个问题。 这样创建了 一个DIV和里面的test   。但如果多个DIV 我怎么样能去到DIV的里面的输入框的值
      

  7.   

    如果要获取他们的ID和value
    那么就用相同的name然后用document.getElementsByName("定义的name")获取,这个是数组
      

  8.   

    document.getElementsById(你定的ID值).value 
      

  9.   

    我怎么样知道用户创建的div最大个数
      

  10.   

    <!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>
    <script>
    var num=1;
    function crediv()
    {
    var div1=document.createElement('div'); 
      div1.style.border="1px solid #0000FF"; 
      div1.style.width = 300 + "px"; 
      div1.style.height =120 + "px"; 
      div1.innerHTML="<input type='text' id='s"+num+"' name='s' value='s"+num+"' /> <input type='text' id='ss"+num+"' name='s' value='ss"+num+"' /> <input type='text' id='sss"+num+"' name='s' value='sss"+num+"' /> ";
    document.body.appendChild(div1);
    num++;
    }
    function showtext()
    {
    var obj=document.getElementsByName("s");
    if(obj){
    for(var i=0;i<obj.length;i++)
    {
    alert(obj[i].value)
    }
    }
    }
    </script>
    </head><body><input type="button" onclick="crediv()" value="创建div" />
    <input type="button" onclick="showtext()" value="查看值" />
    </body>
    </html>
      

  11.   

    我上面举的例子就是
    obj.length的最大个数了
      

  12.   

    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    <script> 
    function abc(i){ 
    var a = document.createElement('div'+i); 
    var b = document.createElement('input'); 
    var c = document.createElement('input'); 
    var d = document.createElement('input'); 
    a.appendChild(b); 
    a.appendChild(c); 
    a.appendChild(d);
    b.id="b"+i//设ID 
    document.body.appendChild(a); 

    </script> 
    </head> 
    <input type="button" value="button" onclick="abc()"/> 
    <body> 
    </body> 
    </html> 
    之后就可以通过ID 'b1'之类获取控件了.
    其他类似.
      

  13.   

    哦来迟了一步,既然写出来了那就贴上吧。<html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>test </title> 
    <script language="javascript"> 
    var i=1;
    function test(){ 
    var divs= document.createElement('div');
    divs.setAttribute("id","div"+i);
    var a = document.createElement('input'); 
    a.setAttribute("id","a"+i);
    var b = document.createElement('input');
    b.setAttribute("id","b"+i);
    var c = document.createElement('input');
    c.setAttribute("id","c"+i);
    divs.appendChild(a); 
    divs.appendChild(b); 
    divs.appendChild(c); 
    document.body.appendChild(divs); 
    i++;
    } </script> 
    </head> 
    <body> 
    <div id="add">
    <input type="button" value="增加" onclick="test();"/> 
    </div>
    <script language="javascript"> 
    function search(){
    var search=document.getElementById("search");
    var searchItem=document.getElementsByTagName("input");
    var line=searchItem[1].value;
    var col=parseInt(searchItem[2].value);
    var divs=document.getElementById("div"+line);
    var s=divs.getElementsByTagName("input");
     searchItem[3].value=s[col-1].value;
    }
    </script> 
    <div id="search">
    行:<input type="text" value="" "/> 
    列:<input type="text" value="" "/> 
    结果:<input type="text" value="" "/>
    <input type="button" value="获取值" onclick="search()"/> 
    </div>
    </body> 
    </html> 
      

  14.   

                 再次感谢。楼上2位大大~  kingwolf_JavaScript  说的话太让人感动了~ 这个世界充满了热情啊,活力!!!!!!!!