ASP實(shí)現(xiàn)動(dòng)態(tài)添加表單內(nèi)容的實(shí)例程序_ASP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:ASP教程:透徹掌握ASP分頁技術(shù)近段時(shí)間看了一些論壇上面關(guān)于分頁的ASP程序依然有許多的關(guān)注者,但里面只有代碼,沒有詳細(xì)的解釋,對(duì)于初學(xué)者來說,這樣總是得不到真正的掌握,此次我將針對(duì)分頁技術(shù)進(jìn)行詳解,讓大家來理解ASP
很多時(shí)候,不知道需要表單的數(shù)目,就需要能對(duì)表單進(jìn)行數(shù)量的控制。收集了如下兩個(gè)效果:
| 以下為引用的內(nèi)容: <html> <body> <form name="form1"> <table id="tb1" border=0> <tr><td><a href="#" onclick="return addFj()">添加附件</a></td></tr> </table> <input type="hidden" name="fjCnt" value="1" /> </form> </body> </html> <script language="javascript"> function addFj() { var oTb = document.getElementById("tb1"); var oTr = oTb.insertRow(0); var name = "thefilename" document.form1.fjCnt.value; document.form1.fjCnt.value=parseInt(document.form1.fjCnt.value) 1; oTr.insertCell(0).innerHTML = "<input id='file' name='" name "' type=file style='width:400px;'> <input type=button onclick='return delFj(this)' value='刪除'>" return false; } function delFj(obj) { obj.parentElement.parentElement.removeNode(true); return false; } </script> |
| 以下為引用的內(nèi)容: <HTML> <HEAD> <STYLE TYPE="text/css"> <!-- .p9{ font-size: 9pt; font-family: 宋體 } td {font-size: 9pt} .tx {height: 16px; width: 30px; border-color: black black #000000; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; background-color: #eeeeee; color: #0000FF} .tx2 {height: 16px;border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; font-size: 9pt; color: #0000FF; border-left-color:#000000; border-right-color:#000000; border-top-color:#000000; border-bottom-color:#000000} .bt {border-left:1px solid #C0C0C0; border-top:1px solid #C0C0C0; font-size: 9pt; border-right-width: 1; border-bottom-width: 1; height: 16px; width: 80px; background-color: #EEEEEE; cursor: hand; border-right-style:solid; border-bottom-style:solid} .tx1 { width: 400 ;height: 20px; font-size: 9pt; border: 1px solid; border-color: black black #000000; color: #0000FF} --> </STYLE> <SCRIPT LANGUAGE="vbscript"> function addfile() dim str str="<table>" if not IsNumeric (window.form1.filenum.value) then window.form1.filenum.value =1 for i=1 to window.form1.filenum.value str=str&"<tr><td valign='middle'>文件"&i&":</td><td><input type='file' name='file"&i&"' class='tx1' value size='20'> 保存為<input type='text' name='file"&i&"' size='20' class='tx2'></td></tr>" next window.uptd.innerHTML =str&"</table>" end function </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> <!-- function Show() { var allnum =document.form1.filenum.value;//獲取有幾個(gè)file for (i=0;i<allnum;i ) { alert("文件框的Name:file" i); } return false; } //--> </SCRIPT> <TITLE></TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"></HEAD> <BODY BGCOLOR="#ffffff" CLASS="p9" onLoad="addfile()"> <FORM METHOD="post" NAME="form1" ACTION="savetofile.asp" ENCTYPE="multipart/form-data"> <TABLE BORDER="0" ALIGN="center" CELLPADDING="0" CELLSPACING="0"> <TR> <TD><DIV ALIGN="center"><FONT COLOR="#0000ff" SIZE="5">保存到文件</FONT></DIV></TD> </TR> <TR> <TD><TABLE WIDTH="750" BORDER="1" ALIGN="center" CELLPADDING="0" CELLSPACING="0" BORDERCOLOR="#111111" STYLE="BORDER-COLLAPSE: collapse"> <TR> <TD HEIGHT="27" COLSPAN="2">上傳 <INPUT NAME="filenum" CLASS="tx2" VALUE="1" SIZE="4"> 個(gè)文件 <INPUT TYPE="button" NAME="Button" CLASS="bt" onClick="addfile" VALUE="設(shè) 定"> </TD> </TR> <TR> <TD> <DIV ID="uptd"> </DIV></TD> </TR> <TR> <TD HEIGHT="30" COLSPAN="2" ALIGN="middle"> <INPUT TYPE="Button" NAME="Button" CLASS="bt" VALUE="看看有幾個(gè)框" onclick="Show()"> <INPUT TYPE="submit" NAME="Button" CLASS="bt" VALUE="上 傳"> <INPUT TYPE="reset" NAME="Button" CLASS="bt" VALUE="重 置"> </TD> </TR> </TABLE></TD> </TR> </TABLE> </FORM> </BODY> </HTML> |
在asp中,動(dòng)態(tài)表單可按普通表單一樣進(jìn)行提交。簡(jiǎn)易的方法是設(shè)定一個(gè)固定表單的name,當(dāng)有多個(gè)表單提交時(shí),各表單數(shù)據(jù)會(huì)自動(dòng)用","隔開,然后用split進(jìn)行分割,再循環(huán)進(jìn)行分別提交。如下:
| 以下為引用的內(nèi)容: <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <script language="javascript"> function addTxtProductNameBox() { var oTb = document.getElementById("TableProductName"); var oTr = oTb.insertRow(0); oTr.insertCell(0).innerHTML ="<input name='txtProductName' type='text'><input type=button onclick='return delTxtProductNameBox(this)' value='刪除'>" return false; } function delTxtProductNameBox(obj) { obj.parentElement.parentElement.removeNode(true); return false; } </script> <% dim rs3,sql3,productNameArray if productName<>"" then set rs3=server.CreateObject ("ADODB.RecordSet") sql3="select * from AmdiProduct" rs3.open sql3,conn,3,2 productNameArray=split(productName,",") for i = 0 to ubound(productNameArray) rs3.addnew rs3("CompanyID")=companyId rs3("ProductName")=productNameArray(i) rs3.update next rs3.close set rs3=nothing end if %> <form name="form1" method="post" action=""> 產(chǎn)品名稱:<a href="#" onclick="addTxtProductNameBox()">添加產(chǎn)品名稱</a> <table id="TableProductName" border=0> <tr><td> </td></tr> </table> <input name="submit" type="submit" id="submit" value="== 提交 ==" /> </form> |
分享:簡(jiǎn)單ASP論壇DIY首先用Access新建一個(gè)數(shù)據(jù)庫(kù),設(shè)取名為luntan,數(shù)據(jù)表的名稱為“information”,建立如下字段:“text”,“name”,“time”,并將“time&rdquo
相關(guān)ASP教程:
- asp FSO 讀寫文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫(kù)實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁模板:ASP內(nèi)建對(duì)象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無組件分頁實(shí)現(xiàn)思路及代碼
ASP教程Rss訂閱編程教程搜索
ASP教程推薦
- asp 中文亂碼問題解決方法
- 解讀ASP程序執(zhí)行SQL語句時(shí)防止注入攻擊的問題
- ASP常見數(shù)學(xué)函數(shù) Abs Atn Cos 等詳細(xì)詳解
- 網(wǎng)頁視頻播放器程序代碼通用代碼
- 通用獲取文章上下各三篇文章的代碼
- 終于找到了ASP下標(biāo)越界的解決方法
- ASP如何防止表單重復(fù)提交
- ASP實(shí)例講解:用分頁符實(shí)現(xiàn)長(zhǎng)文章分頁顯示
- ASP開發(fā)經(jīng)驗(yàn)談 ASP開發(fā)10條經(jīng)驗(yàn)總結(jié)
- ASP把長(zhǎng)的數(shù)字用逗號(hào)隔開顯示
- 相關(guān)鏈接:
復(fù)制本頁鏈接| 搜索ASP實(shí)現(xiàn)動(dòng)態(tài)添加表單內(nèi)容的實(shí)例程序
- 教程說明:
ASP教程-ASP實(shí)現(xiàn)動(dòng)態(tài)添加表單內(nèi)容的實(shí)例程序
。