<%
'申明变量
DimvalName
DimarrName
DimobjConn
DimconnStr
IfRequest.Form("mySubmit")="确定"Then
'数据库链接代码
setobjConn=server.CreateObject("ADODB.connection")
connStr="PROVIDER=SQLOLEDB;Server=(local);DATABASE=test;UID=sa;PWD=123456;"
objConn.Openconnstr
'取得值
valName=Cstr(Request.Form("myName"))
'插入数据库
arrName=split(valName,",")
arrPassword=split(valPassword,",")
'执行插入数据库的过程
Fori=0toUbound(arrName)
'请自行更改SQL语句
objConn.execute("insertintomytable(sname)values('"&Trim(arrName(i))&"')")
Next
Response.write("数据插入成功")
'关闭数据库连接
objConn.close
SetobjConn=nothing
EndIf
%>
<html>
</head>
<body>
<inputtype="button"value="增加一条数据"onclick="addIt()"/>
<formmethod="post"action="test.asp"id="myForm">
<div><inputtype="text"name="myName"/></div>
<inputtype="submit"value="确定"id="mySubmit"name="mySubmit"/>
</form>
</body>
</html>
<scriptlanguage="javascript"type="text/javascript">
function$(obj){
returndocument.getElementById(obj);
}
functionaddIt(){
varmyForm=$("myForm");
varmySubmit=$("mySubmit");
varmyDiv=document.createElement("div");
varmyInput=document.createElement("input");
myInput.setAttribute("type","Text");
myInput.setAttribute("name","myName");
myForm.insertBefore(myDiv,mySubmit);
myDiv.appendChild(myInput);
}
</script>