Rookie 10 days learn the second day of the ASP Tutorial: Form transfer variables

Source: Internet
Author: User
Tags variables reset variable client
Variables | tutorials | 10 days of learning

Previous section: Installing and debugging an ASP environment

  Learning purposes: Learn to transfer variables to the server using form elements, and then display the variables in the client's browser.

First, let's take a look at the form elements. Click here to see the use of specific form labels

Form elements should be placed inside a form field, creating a form field. Then modify the file in the action as an ASP file to accept this form variable. There are two methods, one is post, the variable that the method transmits is not displayed in the browser's address bar, the data can be transmitted in large quantities, and get is displayed in the browser's address bar, and so on to give an example.

Here we look at a form element.

  text field , this is the most basic, the transmission of text information, the general user name, password to use this transmission, but if the password to select the password in the type, this will be replaced by the display of characters, the name of the text field is very important, This name is used in the future, so it is not usually the default name.

Here's an example: if the name of the text field is named, the name used to send the online user registration, in the form field, to the reg.asp, with the Post method, then in the reg.asp to get the variable <%name=request.form ("name %> If you want to display a variable and add a sentence, Response.Write name, which creates a process from the client to the browser and back to the client. If the method is using get, change to Name=request.querystring ("name") in fact the two can be unified as Name=request ("name"). Take a look at the button, there are only two buttons, one is to submit the form of the button, one is re-enter the button. Radio button, a button has a value. In the list also, add list options and values. Here's an example, in fact, all kinds of form elements are similar.

Here is the specific code: (Note: Save the following code as an. htm file.) I save the 1.htm)

<form name= "Form1" method= "Post" action= "reg.asp" >
Name:
<input type= "text" name= "name" >//Text field, named name
<br>
Password:
<input type= "Password" name= "PSW" >//Text field, used to enter the password, named PSW
<br>
<br>
Gender:
<input type= "Radio" name= "Sex" value= "men" >//Radio, named Sex, the value is "male"
Man
<input type= "Radio" name= "Sex" value= "female" >//Radio, the name is sex, the value is "female"
Female <br>
<br>
City:
<select name= "City" >
<option value= "Shanghai" selected> Shanghai </option>//check, everybody analyze it Yourself
<option value= "Beijing" > Beijing </option>
</select>
<br>
<input type= "Submit" Name= "submitted" value= "Submission" >//Submit button
<input type= "reset" name= "Submit2" value= "reset" >
</form>

Here's the reg.asp code to show the information you just received:

<%
Name=request.form ("name")
Psw=request.form ("PSW")
Sex=request.form ("Sex")
City=request.form ("City")
Response.Write Name
Response.Write PSW
Response.Write Sex
Response.Write City
%>

Open the browser in the address bar input: Http://localhost/1.htm as follows: (hehe, because is the practice, I did not beautify the page!) )

After the input information is submitted:

Now we're going to start learning the database! Just connect the form to the corresponding field on the database.

The next section: the establishment of a database



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.