如何创建动态/多重<;textarea>;使用JavaScript
我想添加多个如何创建动态/多重<;textarea>;使用JavaScript,javascript,html,Javascript,Html,我想添加多个textarea,使用Javascript作为no\u of\u descriptioninput HTML标记中的用户输入描述数 这是我的密码: 描述编号 说明1 提交 下面是动态创建html表单字段的方法 <html> <head> <script type='text/javascript'> function addFields(){ var number = document.getE
textarea
,使用Javascript作为no\u of\u description
input HTML标记中的用户输入描述数
这是我的密码:
描述编号
说明1
提交
下面是动态创建html表单字段的方法
<html>
<head>
<script type='text/javascript'>
function addFields(){
var number = document.getElementById("member").value;
var container = document.getElementById("container");
while (container.hasChildNodes()) {
container.removeChild(container.lastChild);
}
for (i=0;i<number;i++){
container.appendChild(document.createTextNode("TextBox " + (i+1)));
var input = document.createElement("input");
input.type = "text";
input.name = "member" + i;
container.appendChild(input);
container.appendChild(document.createElement("br"));
}
}
</script>
</head>
<body>
<input type="text" id="member" name="member" value="">Number of TextBox:<br />
<a href="#" id="filldetails" onclick="addFields()">Add</a>
<div id="container"/>
</body>
</html>
函数addFields(){
var number=document.getElementById(“成员”).value;
var container=document.getElementById(“容器”);
while(container.hasChildNodes()){
container.removeChild(container.lastChild);
}
对于(i=0;i