<script>
var id = 1 ;
function addInput(){
//设置id的生成规则 假如 每次是++1
var form = document.getElementById("formD");
var input = document.createElement("input");
input.id=id+"_input" ;
input.type = "text" ;
form.appendChild(input);
var html = form.innerHTML ;
html += "<button id='"+id+"_button' onclick='delInput("+id+")' >删除</button><br id='"+id+"_br' />" ;
form.innerHTML = html ;
id += 1 ;//完成添加后 给id++1
}
function delInput(id){
var form = document.getElementById("formD");
var input = document.getElementById(id+"_input");
var button = document.getElementById(id+"_button");
var br = document.getElementById(id+"_br");
form.removeChild(input);
form.removeChild(button);
form.removeChild(br);
}
</script>
<button onclick="addInput();" >新增输入框</button>
<form id="formD" >ddd<input type="submit" value="提交" name="B1"></form>
小弟ASP不熟,请大虾写帮忙写完整处理程序
动态INPUT?ASP
js
asp
动态INPUT
------解决方案--------------------
<% dim rs,sql,inputNameArray
if inputName<>"" then
set rs=server.CreateObject ("ADODB.RecordSet")
sql="select * from 表"
rs.open sql,conn,3,3
inputNameArray=split(inputName,",")
for i = 0 to ubound(inputNameArray)
rs.addnew
rs("inputID")=inputId
rs("inputName")=inputNameArray(i)
rs.update
next