Previous Article We talked about how to dynamically add form elements. This time we will talk about how to process the data transmitted from these dynamically added form elements! I will not elaborate on how to dynamically add form elements here! I don't understand. Please refer to the previous article http://www.jb51.net/html/200711/23/12856.htm. the page of the dynamic table element is displayed. Code !
Copy code The Code is as follows: <HTML>
<Head>
<Title> dynamically Add the form Element 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"; // This is required and must be used in processing pages!
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 = "Submit" value = "Submit">
</Label>
<Label>
<Input type = "reset" name = "submit2" value = "reset">
</Label>
</Form>
</Body>
</Html>
The following is the data processing Page code: Copy code The Code is 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">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> dynamically add form elements </title>
</Head>
<Body>
<Div style = "font-size: 13px"> <%
Dim data, arr, n
Data = trim (request. Form ("input1") 'is the name attribute defined in the Code.
Arr = Split (data, ",") 'splits data using the split function!
Response. Write ("this is unpartitioned data :")
Response. Write (data)
Response. Write ("<br> ")
Response. Write ("<br> ")
Response. Write ("this is the data split using the split function :")
Response. Write ("<br> ")
For n = 0 to ubound (ARR)
Response. Write (ARR (n ))
Response. Write ("<br> ")
Next
%> </Div>
</Body>
</Html>