<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>
<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>
http://download.csdn.net/source/308916DHTML参考手册.rar
http://download.csdn.net/source/308913样式表中文手册.chm
http://download.csdn.net/source/304124
<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>
<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>
<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>
那么就用相同的name然后用document.getElementsByName("定义的name")获取,这个是数组
<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>
obj.length的最大个数了
<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'之类获取控件了.
其他类似.
<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>