Home / code / asp

How to request data from a user,

The Request.Form-method is used to read the send information.
The length of send data depends on the fields used. A textarea can be very large.

Warning: All data is send in string, even numbers. They are no ints they are strings. You have to convert them.

How request-tag is written
Request.Form("fieldname1")

So, to get information, you'll need 2 pages 1 in HTML with the form and a second ASP-page.
Or you can combine them both in to one, but lets keep it simple.

The first page (HTML)
<HTML>
<HEAD>
 <TITLE>Program c8.html</TITLE>
</HEAD>
<BODY>

<FORM METHOD=post ACTION=c8.asp>
<TABLE>
  <TR>
    <TD>Name</TD>
    <TD><INPUT TYPE="text" NAME="name1"></TD>
  </TR>
  <TR>
    <TD>Address</TD>
    <TD><INPUT TYPE="text" NAME="address"</TD>
  </TR>
  <TR>
    <TD>City</TD>
    <TD><INPUT TYPE="text" NAME="city"></TD>
  </TR>
</TABLE>
<INPUT TYPE="submit" value="Send">
</FORM>

</BODY>
</HTML>

And the the second(ASP)-page:
<% @language=vbscript %>
<HTML>
<HEAD>
 <TITLE>Program c8.asp</TITLE>
</HEAD>
<BODY>
<H1>What you entered:</H1>

<%
mname1=request.form("name1")
maddress=request.form("address")
mcity=request.form("city")

response.write("name: "& mname1)
response.write("<BR>Address: "& maddress)
response.write("<BR>City: "& mcity)
%>

</BODY>
</HTML>

As you can see, this is a simple program that writes what the user has entered in the HTML-page.

 

TOP

Latest script:

 

Books: