为了让用户通过表单输入数据,可以使用INPUT标记创建各种表单控件,通过将INPUT标记的TYPE属性设置为不同的值,可以创建不同类型的输入型表单控件。
1、单行文本框,格式如下:
一)格式:
<form name="表单的名称" method="get | post" action="URL">
<input type="text" name="字符串" value="字符串" size="整数" maxlength="整数">
</form>
二)属性:
单行文本框具有以下属性(表一)
三)实例的代码:
实例1(1.asp)
<html>
<head><title>简单的登录表单</title>
</head>
<body>
<form method="post" name="form1" action="1.asp">
<table align="center" bgcolor="#d6d3ce" width="500">
<tr bgcolor="#0099cc">
<th colspan="2" align="center">
<font color="#fffff">登录表单</font></th>
</tr>
<tr>
<td align="right" width="150" height="50">用户名:</td>
<td width="350" height="50"><input type="text" name="姓名" size="20"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="reset" name="reset1" value="重设数据"> <input type="submit" name="submit1" value="提交数据">
</tr>
</table>
</form>
<%
dim t1,a,b
t1=request.form("姓名")
if t1<>"" then
a="<center><b>您的姓名为:"
b="</b></center>"
response.write a & t1 & b
else
response.write "<center><b>您还没有输入大名</b></center>"
end if
%>
</body>
</html>
2、在表单中使用密码控件。格式如下:
一)格式:
<form name="表单的名称" method="get | post" action="URL">
<input type="password" name="字符串" value="字符串" size="整数" maxlength="整数">
</form>
其属性有NAME、VALUE、SIZE 和 MAXLENGTH 四项,其含意请参见表一。
二)实例代码:
实例2(2.asp)
<html>
<head><title>简单的登录表单</title>
</head>
<body>
<form method="post" name="form1" action="2.asp">
<table align="center" bgcolor="#d6d3ce" width="500">
<tr bgcolor="#0099cc">
<th colspan="2" align="center">
<font color="#fffff">登录表单</font></th>
</tr>
<tr>
<td align="center" width="250" height="50">用户名:<input type="text" name="姓名" size="14"></td>
<td align="center" width="250" height="50">密码:<input type="password" name="密码" size="14"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="reset" name="rest1" value="重设数据"> <input type="submit" name="submit1" value="提交数据">
</tr>
</table>
</form>
<%
dim t1,ps,a,b,c
t1=request.form("姓名")
ps=request.form("密码")
if t1<>"" and ps<>"" then
a="<center><b>您的姓名为:"
b="</b></center>"
c="<center><b>您的密码为:"
response.write a & t1 & b & "<br>"
response.write c & ps & b
else
response.write "<center><b>您还没有输入大名和密码。</b></center>"
end if
%>
</body>
</html>
3、在表单中添加按钮控件,格式如下:
一)格式:
<form name="表单的名称" method="get | post" action="URL">
<input type="submit|reset|button" name="字符串" value="字符串" onClick="过程名">
</form>
二)属性
按钮控件具有以下属性(表二)
三)事件:
按钮控件还支持 onClick 事件。
四)实例代码:
实例3(3.asp)
(编辑:滁州站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|