Recommended: Dynamic web technology ASP date and time function examples Function syntax description example Now Now() Gets the current date and time of the system Dim MyVar MyVar = Now '' MyVar contains the current date and time. Date Date() Get the current date of the system Dim MyDate MyDate = Date ''
In ASP, you can call your own program through VBScript and other ways.
Example:
Form using method=get
How to use the Request.QueryString command to interact with users.
| The following is the quoted content: <html> <body> <form action=/example/aspe/demo_aspe_reqquery.asp method=get> Your name: <input type=text name=fname size=20 /> <input type=submit value=Submit /> </form> <% dim fname fname=Request.QueryString(fname) If fname<> Then Response.Write(Hello & fname & !<br />) Response.Write(How are you today?) End If %> </body> </html> |
Form using method=post
How to use the Request.Form command to interact with users.
| The following is the quoted content: <html> <body> <form action=/example/aspe/demo_aspe_simpleform.asp method=post> Your name: <input type=text name=fname size=20 /> <input type=submit value=Submit /> </form> <% dim fname fname=Request.Form(fname) If fname<> Then Response.Write(Hello & fname & !<br />) Response.Write(How are you today?) End If %> </body> </html> |
Form using radio buttons
How to interact with users via radio buttons using Request.Form.
| The following is the quoted content: <html> <% dim cars cars=Request.Form(cars) %> <body> <form action=/example/aspe/demo_aspe_radiob.asp method=post> <p>Please select your favorite car:</p> <input type=radio name=cars <%if cars=Volvo then Response.Write(checked)%> value=Volvo>Volvo</input> <br /> <input type=radio name=cars <%if cars=Saab then Response.Write(checked)%> value=Saab>Saab</input> <br /> <input type=radio name=cars <%if cars=BMW then Response.Write(checked)%> value=BMW>BMW</input> <br /><br /> <input type=submit value=Submit /> </form> <% if cars<> then Response.Write(<p>Your favorite car is: & cars & </p>) end if %> </body> </html> |
User input
The Request object can be used to retrieve user information from a form.
Form instance:
| The following is the quoted content: <form method=get action=simpleform.asp> First Name: <input type=text name=fname /> <br /> Last Name: <input type=text name=lname /> <br /><br /> <input type=submit value=Submit /> </form> |
The information entered by the user can be retrieved in two ways: Request.QueryString or Request.Form.
Request.QueryString
The Request.QueryString command is used to collect values in a form using method=get. Information sent from the form using the GET method is visible to all users (appearing in the browser's address bar) and also has a limit on the amount of information sent.
If a user enters Bill and Gates in the form instance above, the URL sent to the server.
Suppose the ASP file simpleform.asp contains the following code:
| The following is the quoted content: <body> Welcome <% response.write(request.querystring(fname)) response.write( & request.querystring(lname)) %> </body> |
The browser will display as follows:
| The following is the quoted content: Welcome Bill Gates |
Request.Form
The Request.Form command is used to collect values in a form using the post method. The information transmitted from the form using the POST method is invisible to the user and there is no limit on the amount of information sent.
If a user enters Bill and Gates in the form instance above, the URL sent to the server.
Suppose the ASP file simpleform.asp contains the following code:
| The following is the quoted content: <body> Welcome <% response.write(request.form(fname)) response.write( & request.form(lname)) %> </body> |
The browser will display as follows:
| The following is the quoted content: Welcome Bill Gates |
Form Verification
Whenever possible, the data entered by the user should be verified (through the client's script). The browser-side verification speed is faster and can reduce the server load.
If user data is entered into the database, you should consider using server-side verification. There is a good way to verify a form on the server side, which is to pass the (verified) form back to the form page instead of going to a different page. The user can then get the error message on the same page. If you do this, it will be easier for users to find errors.
Share: Optimization of ASP pagination effect When learning ASP, the essential thing is to use four major operations: adding, deleting, modifying and checking. The most troublesome thing is to output the data in the database to the client. When there is very little data, for example, there are a few pieces in a database, so you can output it directly. But if there is a lot of data