上一篇文章講到了動(dòng)態(tài)添加表單元素,這次我們來講講怎么樣來處理這些動(dòng)態(tài)添加的表單元素傳過來的數(shù)據(jù)! 怎么樣動(dòng)態(tài)添加表單元素,我這里就不細(xì)說了!不明白的看看上一篇文章https://www.jb51.net/html/200711/23/12856.htm下面是動(dòng)態(tài)添加表單元素的頁面代碼!
復(fù)制代碼 代碼如下:
html >
head>
title>動(dòng)態(tài)添加表單元素BlueShine/title>
/head>
script language="javascript">
function AddElement(mytype){
var mytype,TemO=document.getElementById("add");
var newInput = document.createElement("input");
newInput.type=mytype;
newInput.name="input1";//這個(gè)是必須的,在處理頁中要用到!
TemO.appendChild(newInput);
var newline= document.createElement("br");
TemO.appendChild(newline);
}
/script>
body>
form action="getdata.asp" method="post" name="frm">
p style=" background:#FFEC8B;border:solid 1px #1E90FF;font-size:13px;line-height:200%;width:100px;text-align:center">a style="color:#218868;" href="javascript:void(0)" onClick="AddElement('text')">添加文本框/a>/p>
p id="add">/p>
label>
input type="submit" name="Submit" value="提交">
/label>
label>
input type="reset" name="Submit2" value="重置">
/label>
/form>
/body>
/html>
下面是數(shù)據(jù)處理頁面代碼:
復(fù)制代碼 代碼如下:
%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
title>動(dòng)態(tài)添加表單元素/title>
/head>
body>
div style="font-size:13px">%
dim data,arr,n
data=Trim(Request.Form("input1"))'這就是在代碼中定義的name屬性
arr=split(data,",")'用Split函數(shù)對數(shù)據(jù)進(jìn)行分割!
Response.Write("這是未分割的數(shù)據(jù):")
Response.Write(data)
Response.Write("br>")
Response.Write("br>")
Response.Write("這是用Split函數(shù)分割后的數(shù)據(jù):")
Response.Write("br>")
for n= 0 to ubound(arr)
Response.Write(arr(n))
Response.Write("br>")
Next
%>/div>
/body>
/html>
您可能感興趣的文章:- 原生js實(shí)現(xiàn)獲取form表單數(shù)據(jù)代碼實(shí)例
- Vue.js實(shí)現(xiàn)雙向數(shù)據(jù)綁定方法(表單自動(dòng)賦值、表單自動(dòng)取值)
- form表單數(shù)據(jù)封裝成json格式并提交給服務(wù)器的實(shí)現(xiàn)方法
- JS獲取一個(gè)表單字段中多條數(shù)據(jù)并轉(zhuǎn)化為json格式
- 基于JavaScript實(shí)現(xiàn)帶數(shù)據(jù)驗(yàn)證和復(fù)選框的表單提交
- Vue.js基礎(chǔ)指令實(shí)例講解(各種數(shù)據(jù)綁定、表單渲染大總結(jié))
- 利用JS輕松實(shí)現(xiàn)獲取表單數(shù)據(jù)
- JavaScript動(dòng)態(tài)添加數(shù)據(jù)到表單并提交的幾種方式