How to implement a form item in a dynamically added HTML document
Source: Internet
Author: User
Hello everyone, today and you talk about how to use ASP to implement dynamic Add HTML document form item problem. If you are familiar with HTML, you must know that there is a <form></form> HTML tag. There are tags (elements) between <form> and </form> such as type text, Password, Button, Submit, Reset, and so on. What we're talking about here is dynamically adding a Form item to the dynamic addition of the text element in <Form></Form>. So how do you implement dynamic add form items?
We first analyze and analyze the idea of dynamically adding a form item.
If you want to add one or more text-type form elements to your own or with HTML documents such as FrontPage, Dreamweaver, and static writing. You must have finished writing the first FORM element of type text, and then add the second form element of type text so that it will be added until the number of conditions are met. Let's not say. When you add a new type of text element, you should also display other form elements that already exist and have content and type text. The above mentioned by the static writing of HTML documents to increase the type of text form elements of the method, in fact, we are in the ASP program file dynamic add type to text form elements of the basic ideas. How do you get the content of other form elements that already exist and have content and type text? In the ASP program through the Request.Form ("Textfieldname") can be obtained. The term "textfieldname" refers to an item in <form></form> named "Textfieldname". That means <form><input type=text name=.
"Textfieldname" in the "Textfieldname" ></form>.
Now that we know how to get the contents of a form, we can use this method to get the value of a form element that already exists and has content and type text. When we show these already-valued text items, we can assign the values to the corresponding items. Next, how do we figure out how many form items have content and type text? We can get it in the following way. That is obtained by the Count property of Request.Form ("Textfieldname"). This is because when you get more than one type text in a form and a form element with the same name, we get a set of values, which means that their values are in a collection named Textfieldname. The Count property at this point is the number of similar elements in the collection, so that we can know how many of these form elements are of the type text, and you can use the Loop statement and the Count property to take out the respective values of the collection. You might ask: So how do we get the value of each element of a form named Textfieldname type text in this collection? Before we start, we define a variable I, which has an initial value of 1, and in fact this variable i is the variable we are doing in the loop. Next, we can get the value of each form element named Textfieldname with the Request.Form ("Textfieldname") (I) method. It is also important to note that when we assign the value of a form element that already has a value, type, or text to the corresponding item and display it, we should add a new form item of type text. Why, then? This is to allow us to continue to add new values. Otherwise, you won't be able to add new values until you remove all the form elements that have a value of type text, and that doesn't make the dynamic addition of the form item in the HTML document. So, you must not forget this very important point. Now we know how to get the number of elements in the form with text that satisfies the criteria, and how to get their respective values separately. So how do I control the elements of a form that just has a value and type text? And how do we end up with everything we've said? Then I'll give it the source code, and I'll add some comments or explanations in some places.
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.