ASP code for processing data of form elements dynamically added using JavaScript

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.