网站怎样与用户交互?答案是使用HTML中的表单(form), 表单可以把浏览者输入的数据传送到服务器端,这样服务器端就可以处理表单传送的数据。
语法: <form method = "传送方式" action = "服务器文件">
讲解:1.<form>是成对出现的, 以<form> 开始, 以 </form>结束,表单都必须放在其之间。
2.method 传送方式, get/post 是后端程序员考虑的问题
3.action 浏览者输入的数据被传送到的地方,比如一个php页面, (save.php)
<form method="post" action="save.php">
<label for="username">用户名:</label>
<input type="text" name="username" />
<label for="pass">密码:</label>
<input type="password" name="pass" />
</form>
文本输入框,密码输入框
当用户需要在表单中键入字母,数据等,就要用到文本输入框,文本输入框也可以转化为密码输入框
语法:
<form>
<input type = "text/password" name = "名称" value = "文本" />
</form>
讲解:1.type :
当 type 为 text时,为文本输入框
当 type 为 password 时, 为密码输入框
2.name :为文本框命名,以备后台asp php使用
3.value :为文本输入框设置默认值(一般起提示作用)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>文本输入框、密码输入框</title>
</head>
<body>
<form method="post" action="save.php">
账户:
<input type = "text" name = "myName" />
<br />
密码:
<input type = "password " name = "pass"/>
</form>
</body>
</html>
结果:
账户:
密码: