• 表 单 1


    初识表单post和get提交

    表单

    表单元素格式

    例子:

    • form:表单
    • action : 表单提交的位置,可以是网站,也可以是一个请求处理地址
    • method: post/get 提交方式
    • get方式提交:可以再URL中看到我们提交的信息,不安全,高效
    • post :比较安全,传输大文件,
    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>登录注册title>
    6. head>
    7. <body>
    8. <h1>注册h1>
    9. <form action="first.html" method="post">
    10. <p>名字:<input type="text" name="username">p>
    11. <p>密码:<input type="password" name="pwd">p>
    12. <p>
    13. <input type="submit">
    14. <input type="reset">
    15. p>
    16. form>
    17. body>
    18. html>

    输出结果:

    (1)get提交

    (2)post提交(按住f12在network可以查看密码)


    文本框和单选框

    例子:

    (1)文本框

    • value="haha"    默认初始值
    • maxlength="8"   最长能写几个字符
    • size="30"       文本框的长度

    (2)密码框

    • input type="password"

    (3)单选框标签

    • input type="radio"
    • value : 单选框的值
    • name: 表示组
    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>登录注册title>
    6. head>
    7. <body>
    8. <h1>注册h1>
    9. <form action="first.html" method="post">
    10. <p>名字:<input type="text" name="username" value="haha" maxlength="8"/>p>
    11. <p>密码:<input type="password" name="pwd"/>p>
    12. <p>
    13. <input type="radio" value="man" name="sex"/>
    14. <input type="radio" value="woman" name="sex"/>
    15. p>
    16. <p>
    17. <input type="submit"/>
    18. <input type="reset"/>
    19. p>
    20. form>
    21. body>
    22. html>

     输出结果:


    按钮和多选按钮

        按钮

    •     input type="button" 普通按钮
    •     input type="image"  图片按钮
    •     input type="submit" 提交按钮
    •     input type="reset"  重置

    例子:

    1. html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <title>登录注册title>
    6. head>
    7. <body>
    8. <h1>注册h1>
    9. <form action="first.html" method="post">
    10. <p>名字:<input type="text" name="username" value="haha" maxlength="8"/>p>
    11. <p>密码:<input type="password" name="pwd"/>p>
    12. <p>
    13. <input type="radio" value="man" name="sex"/>
    14. <input type="radio" value="woman" name="sex"/>
    15. p>
    16. <p>
    17. 爱好:
    18. <input type="checkbox" value="sleep" name="hobby"/>睡觉
    19. <input type="checkbox" value="code" name="hobby"/>敲代码
    20. <input type="checkbox" value="chat" name="hobby"/>聊天
    21. <input type="checkbox" value="game" name="hobby"/>游戏
    22. p>
    23. <p>
    24. 按钮:
    25. <input type="button" value="点击变长" name="but1"/>
    26. <input type="image" src="../resource/img/5efaffbac96db.jpg"/>
    27. p>
    28. <p>
    29. <input type="submit"/>
    30. <input type="reset"/>
    31. p>
    32. form>
    33. body>
    34. html>

    输出结果:

  • 相关阅读:
    Leetcode.260 只出现一次的数字 III
    uView实现全屏选项卡
    指针,动态内存分配
    群晖7.2版本安装Jellyfin
    推荐一款.NET开源的轻量级分布式服务框架
    【PAT甲级 - C++题解】1049 Counting Ones
    体育场馆LED显示屏的分类及应用
    解压从Google Drive下载的分文件zip
    新加坡服务器搭建网站出现PHP错误怎么处理?
    代码随想录30——回溯:332重新安排行程、51N皇后、37解数独
  • 原文地址:https://blog.csdn.net/qq_46423017/article/details/126261777