The last article talked about adding form elements dynamically, and this time we'll talk about how to handle the data from these dynamically added form elements! How to add the form element dynamically, I don't have to elaborate here! Look at the last article http://www.jb51.net/html/200711/23/12856.htm the following is the page code that dynamically adds form elements!
Copy Code code as follows:
<title> dynamically add table cell element blueshine</title>
<script language= "JavaScript" >
function AddElement (mytype) {
var Mytype,temo=document.getelementbyid ("Add");
var newinput = document.createelement ("input");
Newinput.type=mytype;
Newinput.name= "INPUT1";//This is a must, in the processing page to use!
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 ') > Add text Box </a> </p>
<p id= "Add" ></p>
<label>
<input type= "Submit" name= "Submission" value= "submitted" >
</label>
<label>
<input type= "reset" name= "Submit2" value= "reset" >
</label>
</form>
</body>
Here is the data processing page code:
Copy Code code as follows:
<% @LANGUAGE = "VBSCRIPT" codepage= "936"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> dynamically adding table cell elements </title>
<body>
<div style= "font-size:13px" ><%
Dim data,arr,n
Data=trim (Request.Form ("input1")) ' This is the Name property defined in code
Arr=split (data, ",") ' uses the Split function to split the dataset!
Response.Write ("This is an undivided data:")
Response.Write (data)
Response.Write ("<br>")
Response.Write ("<br>")
Response.Write ("This is the split data with the Split function:")
Response.Write ("<br>")
For n= 0 To UBound (arr)
Response.Write (arr (n))
Response.Write ("<br>")
Next
%></div>
</body>