HTML:表单收集数据

发布于:2025-04-19 ⋅ 阅读:(17) ⋅ 点赞:(0)
DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="/save" method="post">
        <label for="name">姓名:</label>
        <input type="text" id="name" name="name" required>
        <!-- 有label标签,点击文字也等于点击输入框 -->
        <br>
        年龄:
        <input type="number" id="age" name="age" required>
        <br>
        <label for="email">邮箱:</label>
        <input type="email" id="email" name="email" required>
        <br>
        <label for="password">密码:</label>
        <input type="password" id="password" name="password" required>
        <br>
        性别:
        <input type="radio" id="male" name="gender" value="male">
        <label for="male">男</label>
        <input type="radio" id="female" name="gender" value="female">
        <label for="female">女</label>
        <br>
        爱好:
        <input type="checkbox" id="reading" name="hobbies" value="reading">
        <label for="reading">阅读</label>
        <input type="checkbox" id="sports" name="hobbies" value="sports">
        <label for="sports">体育</label>
        <br>
        <!-- 生日 -->
        <label for="birthday">生日:</label>
        <input type="date" id="birthday" name="birthday" required>
        <br>
        <!-- 时间 -->
        <label for="time">时间:</label>
        <input type="time" id="time" name="time" required>
        <br>
    <!-- 上传文件 -->
        <label for="file">选择文件:</label>
        <input type="file" id="file" name="file" required>
        <br>
        <!-- 下拉框 -->
        <label for="country">国家:</label>
        <select id="country" name="country" required>
            <option value="China">中国</option>
            <option value="USA">美国</option>
            <option value="Japan">日本</option>
        </select>
        <br>
        <!-- 多行文本框 -->
        <label for="message">留言:</label>
        <textarea id="message" name="message" rows="4" cols="50" required></textarea>
        <br>
        <!-- 定义隐藏的表单域 -->
        <input type="hidden" name="hidden_field" value="hidden_value">
        <br>
        <input type="submit" value="提交"></input>
        <input type="reset" value="重置"></input>
        <!-- 按钮 -->
        <button type="button">按钮</button>

        
        <input type="checkbox" name="checkbox" value="checkbox_value">复选框</input>
        <input type="radio" name="radio" value="radio_value">单选框</input>

    </form>
</body>
</html>


网站公告

今日签到

点亮在社区的每一天
去签到