使用表单标签 与用户交互

网站怎样与用户交互?答案是使用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>
结果:

账户:  
密码:  

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值