ASP动态添加文本框,一起写入数据库怎么实现,高手帮忙,谢谢!
我想做一个动态添加文本框的页面,点击“增加”表格可以自动添加一行,同时添加一行文本框。最后统一“提交”写入到数据库里面的多条记录。动态添加的代码已经找到了,但是不知道怎么实现写入到ACCESS数据库里面去。哪位高手帮忙写一段最后能批量添加到ACCESS数据库的代码啊,十分感谢!动态添加文本框的代码如下:
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www."> <html xmlns="http://www."> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <script language="JavaScript"> function addOrderRow(tab,rowNum,colNum,obj,addType) { var detailbody=document.getElementById(tab); var row = document.createElement("tr"); var newrow=obj.parentNode.parentNode.innerHTML; if(addType=='add'){ var row = detailbody.insertRow(); for(var i=0;i<obj.parentNode.parentNode.childNodes.length;i++){ var cell=row.insertCell(); cell.innerHTML=obj.parentNode.parentNode.childNodes[i].innerHTML; //alert(obj.parentNode.parentNode.childNodes[i].innerHTML); //如果表单中有值就清空 for(var k=0;k<cell.childNodes.length;k++){ if (cell.childNodes[k].type == 'text') { cell.childNodes[k].value = ''; } if (cell.childNodes[k].type == 'textarea') { cell.childNodes[k].value = ''; } if (cell.childNodes[k].type == 'checkbox') { cell.childNodes[k].checked = false; } if (cell.childNodes[k].type == 'radio') { cell.childNodes[k].checked = false; } if (cell.childNodes[k].type == 'select-multiple') { cell.childNodes[k].selectedIndex = -1; } if (cell.childNodes[k].type == 'select-one') { cell.childNodes[k].selectedIndex = -1; } } //cell.innerHTML=arr[i]; } obj.parentNode.parentNode.childNodes[0].innerHTML+='<input type=hidden id=text'+(detailbody.childNodes.length+1)+'>'; }else if(addType=='copy'){ //copy //detailbody.insertRow().insertCell().innerHTML = newrow; ok var row = detailbody.insertRow(); for(var i=0;i<obj.parentNode.parentNode.childNodes.length;i++){ var cell=row.insertCell(); cell.innerHTML=obj.parentNode.parentNode.childNodes[i].innerHTML; } obj.parentNode.parentNode.childNodes[0].innerHTML+='<input type=hidden id=text'+(detailbody.childNodes.length+1)+'>'; }else{ //delete if(confirm("Are you sure to delete this record?")){ obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode); }else{ return false; } } //只显示最后一个add按钮 var leg = detailbody.childNodes.length; if(leg>1){ for(var j=0;j<leg-2;j++){ document.getElementsByName("btnAdd")[j].style.visibility="hidden"; } document.getElementsByName("btnAdd")[leg-2].style.visibility="visible"; //document.getElementsByName("btnDelete")[0].style.visibility="hidden"; } //显示除第一个外所有delete按钮 if(leg>1){ for(var j=1;j<leg-1;j++){ document.getElementsByName("btnDelete")[j].style.visibility="visible"; } } } </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <div id="outlineChildaaa" style="cursor:auto" > <table width="700" border="1" cellpadding="5" cellspacing="0" bordercolor="#E8E09F" id="detailItem"> <tbody id="detailItemBody"> <tr> <td width="38%" nowrap="" bgcolor="#F3EFCD" class="STYLE7 td1"><strong>名称</strong></td> <td width="19%" nowrap="" bgcolor="#F3EFCD" class="STYLE7 td1"><strong>颜色</strong></td> <td width="10%" nowrap="" bgcolor="#F3EFCD" class="STYLE7 td1"><strong>数量</strong></td> <td width="10%" nowrap="" bgcolor="#F3EFCD" class="STYLE7 td1"><strong>排序</strong></td> <td width="23%" bgcolor="#F3EFCD" class="td1 STYLE7"><strong>操作</strong></td> </tr> <tr id="tr1"> <td width="38%" id="td1" > <input type="hidden" name="SampleOrderContentID"/> <input type="text" size="30" name="name" id="ItemNo"/></td> <td width="19%" nowrap=""><input type="text" size="10" name="color" id="ItemNo1"/></td> <td width="10%" nowrap=""><input type="text" size="6" name="quantity" id="Nickname1"/></td> <td width="10%" nowrap=""><input type="text" size="6" name="px" id="cleats1"/></td> <td width="23%" nowrap=""> <input type="button" onclick="addOrderRow('detailItemBody',2,11,this,'add')" value="增加" id="btnAdd1" name="btnAdd"/> <input type="button" onclick="addOrderRow('detailItemBody',2,11,this,'copy')" value="复制" id="btnCopy" name="btnCopy"/> <input type="button" onclick="addOrderRow('detailItemBody',2,11,this,'delete')" value="删除" id="btnDelete" name="btnDelete" style="visibility:hidden "/></td> </tr> </tbody> </table> <table width="700" border="0"> <tr> <td><div align="center"> <label> <input type="submit" name="Submit" value="提交" /> </label> </div></td> </tr> </table> </div> </form> </body> </html>