|
Froms are used to submit data from
the clients pc browser to the server.
Forms and submitting data to the
server.
Structure of a simple form. This
form has one input field named
myName.
The form has a submit button named
B1.
When the submit button is clicked , the form is being sent to the
page
pagename.asp. This is
defined in the action directive.
<form
method="POST" action="pagename.asp">
<input type="text" name="myName" size="20">
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2">
</form> |
Another form with
different type of submit value, which is beign submitted to itself.
When the page runs on the server, the language is checking if its
loading for the first time or the submit button has been pushed. If
the button is pushed, it captures the data sent to it.
To capture the data, the request() function is is being called.
<%
pagename="testform.asp"
If request("B1")<>"" Then
Response.write "Name: " & request("Name") & "<br>"
Response.write "Address: " & request("address") & "<br>"
Response.write "Sex: " & request("Sex") & "<br>"
Response.write "Checkbox: " & request("CheckBox") & "<br>"
End if
%>
<form method="POST" action=<%=pagename%>>
Name<br>
<input type="text" name="name" size="20"><br>
<br>
Address<br>
<textarea rows="2" name="address" cols="20"></textarea><br>
<br>
Sex<br>
<input type="radio" value="Male" checked
name="sex">Male<input type="radio" name="sex"
value="Female">Female<br>
<br>
<input type="checkbox" name="CheckBox" value="ON">Check me
in.<br>
<br>
<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2">
</form> |
[Download
Sample Code]
|