Introduction to ASP Programming (II): Understanding the form

Source: Internet
Author: User
Tags modify
Programming Statement: ASP Programming Entry Advanced series article copy from http://www.cnbruce.com/blog/part run code please go to the station for online testing
To tell the truth, whether it is asp,php or JSP for network programming, can not be separated from the user interaction.
and man-machine conversation platform, basically rely on the corresponding text, list box input, and then through the button submitted to the database.
So learning network programming must be aware of these input platform related things: forms (Form)
The basic format is as follows:
<form name= "Form1" action= "xxx.asp" method= "POST" >
<input type= "text" name= "Yourname" >
<select name= "Selectwhat" >
<option>aaa</option>
<option>aaa</option>
</select>
<textarea name= "Textinit" rows=5 cols=10></textarea>
</form>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]
Can be summed up: The form is included in the relevant content within <form>...</form>.
The interior can be divided into three main categories: Input,select,textarea

First, look at the <form> internal parameters
Parameter name: Used to represent the unique name of the form, to facilitate a page to create multiple forms without confusing, and of course, to accept the page's confirmation relationship.
Parameter action: It is obvious that all content in the current form will be sent to a page for processing. Processing includes receiving information, database comparisons, additions, modifications, and so on.
Parameters method: The form's submission method, including two methods: Post and get. Post is the transmission of information content, get is the transfer URL value, the specific usage will be described in the next section, "Built-in object request"

Second, to look at the input related
Input represents an input object in form forms that is divided into text input boxes, password input boxes, radio/check boxes, submit/reset buttons, and so on, as described below.
1,type=text
input type is text, this is the most we see is also used most, such as login to enter the user name, registration input phone number, email, home address and so on. Of course this is also the default type of input.
Parameter name: The same is the name of the text input box that is represented.
Parameter size: The length of the input box.
Parameter maxlength: The maximum number of characters allowed in the input box.
Parameter value: The default value in the input box
Special parameter ReadOnly: Indicates that the box can only be displayed, you cannot add modifications.
<form>
Your name:
<input type= "text" name= "yourname" size= "maxlength=" "value=" the length of the input box is 30, allowing the maximum number of characters to be "><br>
<input type= "text" name= "yourname" size= "" Maxlength= "" ReadOnly value= "You can only read can not modify" >
</form>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

2,type=password
I don't need to say, a look at the password input box, the biggest difference is when entering information in this input box is displayed as a confidential character.
parameter is similar to "Type=text".
<form>
Your password:
<input type= "password" name= yourpwd "size=" maxlength= "value=" > Password length less than 15
</form>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

3,type=file
When you upload a picture in the BBS, upload the attachment in the email must be something:
Provides a platform for the input of a file directory, with name,size parameters.
<form>
Your file:
<input type= "File" Name= "Yourfile" size= ">"
</form>


[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

4,type=hidden
A very noteworthy one, usually called a hidden field: if a very important piece of information needs to be submitted to the next page, it cannot or cannot be expressed.
In a word, you can't see where hidden is in the page. The most useful is the value of hidden.
<form name= "Form1" >
Your hidden info here:
<input type= "hidden" name= "Yourhiddeninfo" value= "cnbruce.com" >
</form>
<script>
Alert ("The value of the hidden field is" +document.form1.yourhiddeninfo.value)
</script>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

5,type=button
A standard Windows-style button, of course, to allow the button to jump to a page also need to join the write JavaScript code
<form name= "Form1" >
Your button:
<input type= "button" Name= "Yourhiddeninfo" value= "go,go,go!" "Onclick=" window.open (' http://www.cnbruce.com ') >
</form>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

6,type=checkbox
Multi-selection box, common in the registration of the choice of hobbies, personality, and other information. Parameter has Name,value and special parameter checked (indicates default selection)
In fact, the most important thing is value, which is submitted to the processing page is value. (Attached: The name value can be different, but not recommended.) )
<form name= "Form1" >
A:<input type= "checkbox" Name= "Checkit" value= "a" checked><br>
B:<input type= "checkbox" Name= "Checkit" value= "B" ><br>
C:<input type= "checkbox" Name= "Checkit" value= "C" ><br>
</form>
The name value can be different but not recommended <br>
<form name= "Form1" >
A:<input type= "checkbox" Name= "Checkit1" value= "a" checked><br>
B:<input type= "checkbox" Name= "Checkit2" value= "B" ><br>
C:<input type= "checkbox" Name= "Checkit3" value= "C" ><br>
</form>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

7,type=radio
That is, the single selection box, appears in the multiple select one of the page settings. The parameters also have Name,value and special parameter checked.
Unlike the checkbox, the name value must be the same, otherwise you cannot select one more. It is also the value of the value that is submitted to the processing page.
<form name= "Form1" >
A:<input type= "Radio" name= "Checkit" value= "a" checked><br>
B:<input type= "Radio" name= "Checkit" value= "B" ><br>
C:<input type= "Radio" name= "Checkit" value= "C" ><br>
</form>
The following is an example of a different name value, which does not achieve the effect of more than one choice <br>
<form name= "Form1" >
A:<input type=&



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.