1. 用户提交数据
  2. 提交数据的两个要素:数据名称+数据的值
  3. action要把数据提交到哪里,接收的地址
  4. input决定input显示什么的,不是input本身而是type属性
  5. form是块级元素block element
  6. input是内联标签 inline-block element
  7. <form method="get|post" action="url">
  8. <input>
  9. <input type="text">
  10. <input type="password">
  11. </form>
  1. <form method="get" action="">
  2. <p>
  3. 用户名:<input type="text">
  4. </p>
  5. <p>
  6. 密码:<input type="password" id="password1">
  7. </p>
  8. <p>
  9. <input type="submit" value="登录">
  10. </p>
  11. </form>

点击显示,数据提交.html?

  1. <form method="get" action="">
  2. <p>
  3. 用户名:<input type="text" name="username">
  4. </p>
  5. <p>
  6. 密码:<input type="password" id="password1" name="password">
  7. </p>
  8. <p>
  9. <input type="submit" value="登录" >
  10. </p>
  11. </form>

点击显示,数据提交.html?username=&password=

label

内联元素

  1. <label for="">123</label>123

image.png

  1. <form action="get" action="">
  2. <label for="username">用户名</label>
  3. <input type="text" id="username" name="username">
  4. </form>

image.png

label的for属性值与某一个input的id值相同时,点击label可以聚集给input输入框

  1. <form action="get" action="">
  2. <label for="username">用户名</label>
  3. <input type="text" id="username" name="username"><br>
  4. <label for="password">密码</label>
  5. <input type="password" id="password" name="password"><br>
  6. 密码用md5保存
  7. 什么是md5:消息摘要的算法,不可逆加密算法,只要加了密,不能再解密,这种方式不用提供密钥
  8. </form>
  1. <form action="get" action="">
  2. <label for="username">用户名</label>
  3. <input type="text" id="username" name="username" readonly="readonly" value="123"
  4. disabled="disabled"><br>
  5. <label for="password">密码</label>
  6. <input type="password" id="password" name="password"><br>
  7. </form>

image.png

  1. <form action="get" action="">
  2. <label for="username">用户名</label>
  3. <input type="text" id="username" name="username" value="1234"
  4. disabled="disabled"><br>
  5. <label for="password">密码</label>
  6. <input type="text" id="password" name="password" value="123" readonly="readonly"><br>
  7. <input type="submit" value="提交">
  8. </form>

数据提交表单/get?password=123
readyonly只读,表单提交提交出去
disabled禁用,表单提交不提交被禁用的数据

image.png

单选

  1. <form method="get" action="">
  2. <input type="radio" id="male" checked="checked">
  3. <label for="male">男士</label>
  4. <input type="radio" id="female">
  5. <label for="female">女士</label>
  6. </form>

image.png

  1. <form method="get" action="">
  2. <input type="radio" id="male" checked="checked" name="sex">
  3. <label for="male">男士</label>
  4. <input type="radio" id="female" name="sex">
  5. <label for="female">女士</label>
  6. </form>

image.png

  1. <form method="get" action="">
  2. <input type="radio"
  3. id="male"
  4. checked="checked"
  5. name="sex"
  6. value="male">
  7. <label for="male">男士</label>
  8. <input type="radio"
  9. id="female"
  10. name="sex"
  11. value="female">
  12. <label for="female">女士</label>
  13. <br>
  14. <input type="submit">
  15. </form>

同一个name就可以多选一,通过名字区分,发给服务器得发数据名称:数据集的值,这是一一对应的

  1. <form action="" method="get">
  2. <select name="lang" id="">
  3. <option value="">请选择</option>
  4. <option value="js">JavaScript</option>
  5. <option value="java">JAVA</option>
  6. <option value="php">PHP</option>
  7. <option value="python">Python</option>
  8. </select>
  9. <br>
  10. <input type="submit" value="提交">
  11. </form>