ASP's code for handling form element data added dynamically with JavaScript-application tips

Source: Internet
Author: User
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>

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.