日期:2014-05-18  浏览次数:20442 次

跪求各位大虾帮帮忙,动态生成textbox的问题,请进来看!
我想做的是:web下,在一个table中,三个textbox为一行的,光标落在任意一个textbox内或输入任何值都会自动生成下一行,当对第二行进行对第一行同样的操作时依然自动生成下一行,而且不消失,可以一直生成下去。
请各位大虾帮帮忙,小弟现在一头雾水,唯一的办法就是请各位大虾帮忙了,在此先谢谢了!!


------解决方案--------------------

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> test </title>
<script type= "text/javascript ">
function AddText()
{
var e = document.getElementById( "tempTalbe ");
var row = e.insertRow();
var cell = row.insertCell();
for(var i = 0 ; i < 3;i++)
{
var text = document.createElement( " <input type= 'text ' onfocus= 'AddText() '/> ");
text.id = "test " + e.rows.length.toString() + i.toString();
text.value = "test " + e.rows.length.toString() + i.toString();
cell.appendChild(text);
}
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<table id= "tempTalbe ">
<tr>
<td>
<input type= "text " id= "test10 " value= "test10 " onfocus= "AddText() " />
<input type= "text " id= "test11 " value= "test11 " onfocus= "AddText() " />
<input type= "text " id= "test12 " value= "test12 " onfocus= "AddText() " />
</td>
</tr>
</table>
</form>
</body>
</html>
自己改改吧,大致的样子出来了
------解决方案--------------------
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head>
<title> Untitled Page </title>
<script language= "javascript " type= "text/javascript ">
function newInput(e)
{
e.parentNode.innerHTML += " <br/> <input type= 'text ' name= 'a ' onchange= 'newInput(this) '/> ";
}
</script>
</head>
<body>
<form name= "mform " method= "post " action= "details.aspx " id= "mform ">
<input id= "Text1 " type= "text " onchange= 'newInput(this) '/> <br />
<input id= "Text2 " type= "text " onchange= 'newInput(this) '/>
<br />
<input id= "Text3 " type= "text " onchange= 'newInput(this) '/>
</form>
</body>
</html>