为了让用户通过表单输入数据,可以使用INPUT标记创建各种表单控件,通过将INPUT标记的TYPE属性设置为不同的值,可以创建不同类型的输入型表单控件。
1、单行文本框,格式如下:
一)格式:
<form name="表单的名称" method="get | post" action="URL">
<input type="text" name="字符串" value="字符串" size="整数" maxlength="整数"> </form>
二)属性:
单行文本框具有以下属性(表一)
属 性 | 含 意 |
NAME | 指定文本框的名称,通过它可以在脚本中引用该文本框。 |
VALUE | 指定单行文本框的初始值。 |
SIZE | 指定单行文本框的宽度。 |
MAXLENGTH | 指定允许在文本框内输入的最大字符数。 |
三)实例的代码:
实例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、在表单中添加按钮控件,格式如下:
零七网部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与零七网进行文章共享合作。