Blogger Information
Blog 23
fans 0
comment 3
visits 23409
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
HTML表格与表单控件及文件域和隐藏域
a.
Original
869 people have browsed it

课程表作业

  1. <table border="1" cellspacing="0">
  2. <caption>
  3. 课程表作业
  4. </caption>
  5. <thead>
  6. <tr>
  7. <th colspan="2"></th>
  8. <th>周一</th>
  9. <th>周二</th>
  10. <th>周三</th>
  11. <th>周四</th>
  12. <th>周五</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <td rowspan="4">上午</td>
  18. <td>第一节</td>
  19. <td>语文</td>
  20. <td>数学</td>
  21. <td>英语</td>
  22. <td>化学</td>
  23. <td>物理</td>
  24. </tr>
  25. <tr>
  26. <td>第二节</td>
  27. <td>数学</td>
  28. <td>英语</td>
  29. <td>化学</td>
  30. <td>物理</td>
  31. <td>生物</td>
  32. </tr>
  33. <tr>
  34. <td>第三节</td>
  35. <td>体育</td>
  36. <td>政治</td>
  37. <td>历史</td>
  38. <td>数学</td>
  39. <td>语文</td>
  40. </tr>
  41. <tr>
  42. <td>第四节</td>
  43. <td>英语</td>
  44. <td>化学</td>
  45. <td>物理</td>
  46. <td>生物</td>
  47. <td>音乐</td>
  48. </tr>
  49. <tr align="center">
  50. <td colspan="7">中午休息</td>
  51. </tr>
  52. <tr>
  53. <td rowspan="3">下午</td>
  54. <td>第一节</td>
  55. <td>体育</td>
  56. <td>语文</td>
  57. <td>数学</td>
  58. <td>英语</td>
  59. <td>物理</td>
  60. </tr>
  61. <tr>
  62. <td>第二节</td>
  63. <td>化学</td>
  64. <td>政治</td>
  65. <td>体育</td>
  66. <td>历史</td>
  67. <td>生物</td>
  68. </tr>
  69. <tr>
  70. <td>第三节</td>
  71. <td colspan="2">课外活动</td>
  72. <td>大扫除</td>
  73. <td colspan="2">班会</td>
  74. </tr>
  75. </tbody>
  76. </table>

表单控件

  • action:处理表单的程序 method:表单提交类型
  • 默认为GET,数据参数直接放在url地址中 POST:表单的数据在请求头中,更安全
  • type:控件类型 text:文本,email:邮箱,password:密码,namber:数字
  • name:数据的变量名 value:表单的默认内容 placeholder:提示 required:必选
  1. <form action="处理程序" method="POST">
  2. <!--文本框-->
  3. <label for="username">账号:</label>
  4. <input
  5. type="text"
  6. id="username"
  7. name="username"
  8. value="admin"
  9. placeholder="至少6位"
  10. autofocus
  11. required
  12. />
  13. <label for="email">邮箱:</label>
  14. <input
  15. type="email"
  16. id="email"
  17. name="email"
  18. placeholder="admin@qq.com"
  19. required
  20. />
  21. <label for="age">年龄:</label>
  22. <input type="number" id="age" name="age" min="10" max="150" required />
  23. <label for="password">密码:</label>
  24. <input type="password" id="password" name="password" required />
  25. <label for="password1">确认:</label>
  26. <input type="password1" id="password1" name="password1" required />
  27. <button>提交</button>
  28. </form>
  29. <!--单选框和复选按钮和下拉列表-->
  30. <form action="" method="POST">
  31. <label for="">性别:</label>
  32. <div>
  33. <!--一组单选框按钮必须用同一个名称的name属性值,否则无法实现值的唯一性-->
  34. <input type="radio" name="gender" value="male" id="male" />
  35. <label for="male"></label>
  36. <input type="radio" name="gender" value="female" id="female" />
  37. <label for="female"></label>
  38. <input type="radio" name="gender" value="secret" id="secret" />
  39. <label for="secret">保密</label>
  40. </div>
  41. <label for="#">兴趣:</label>
  42. <div>
  43. <!--复选框的name属性值应该写数组格式名称,这样才能确保服务器可以接收到一组值 -->
  44. <input type="checkbox" name="hobby[]" value="game" id="game" />
  45. <label for="game">打游戏</label>
  46. <input type="checkbox" name="hobby[]" value="shoot" id="shoot" />
  47. <label for="shoot">摄影</label>
  48. <input type="checkbox" name="hobby[]" value="music" id="music" />
  49. <label for="music">听歌</label>
  50. <!--下拉列表-->
  51. <label for="">学历</label>
  52. <!--multiple size="2"-->
  53. <select name="edu">
  54. <option value="1">小学</option>
  55. <option value="2">初中</option>
  56. <option value="3" selected>高中</option>
  57. <option value="4">大学</option>
  58. <!--label属性的优先级大于 Option内部的文本
  59. <option value="5" label=“自学“ </option>-->
  60. </select>
  61. </div>
  62. <button>提交</button>
  63. </form>

文件域隐藏域

文件域

  • 1.请求类型必须是:POST
  • 2.将表单数据编码设置为enctypc=“multipart/form-data”
    1. <form action="cc.php" method="POST" enctypc="multipart/form-data">
    2. <label for="file">选择文件:</label>
    3. <input type="file" name="file" id="file" />
    4. <button>上传文件</button>
    5. </form>

隐藏域

<input type="hidden" name="MAX_FILE_SIZE" value="100000" />

表单的form属性

  • 通过关联绑定FORM标签外的控件也能获取到表单数据
  • Input和button都要绑定才能提交数据
    1. <form action="#" method="POST" id="register">
    2. </form><label for="name">用户名:</label>
    3. <input type="text form="register" name="name" id="name">
    4. <button form="register">提交</button>
  • 尽管form可以将控件写到任意地址,仍然能获取到数据的值,但不要这样做,第一影响布局,第二代码混乱
  • 但是,用在JS中,获取数据将变得非常的方便
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
1 comments
a. 2020-12-10 08:25:47
<option value="5" label=“自学“> </option> 掉了一个尖括号
1 floor
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!