表单提交
表单提交
什么是表单?
个人理解表单就是需要用户操作然后将数据提交操作的模块,重点是 form标签的使用
表单元素格式
| 属性 | 说明 | 
|---|---|
| type | 指定的元素的类型。text、password、checkbox(复选框)、radio(单选框)、submit、reset、file、hide、image和button,默认为text | 
| name | 指定表单元素的名称 | 
| value | 元素的初始值,type为radio时必须指定一个值 | 
| size | 指定表单元素的宽度。当type为text或者password时,表单元素的大小以字符为单位。对于其他类型,宽度以像素为单位 | 
| maxlength | type为text或password时,输入的最大字符数 | 
| checked | type为radio或者checkbox时,指定按钮是否被选中 | 
注:radio英文为录音机指代单选框是因为老式的录音机有一排按钮,按了一个其他的都会弹起,由此命名。
示例
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表单提交</title>
</head>
<body>
<h1>注册</h1>
<form action="myfirstweb.html" method="get">
    <p>用户名:<input type="text" name="username" maxlength="10" size="30"></p>
    <p>密码:<input type="password" name="pwd" maxlength="8" size="25"></p>
    <p>性别:
        <input type="radio" value="woman" name="sex">女
        <input type="radio" value="man" name="sex">男
    </p>
    <p>兴趣:
        <input type="checkbox" value="paint" name="interest">画画
        <input type="checkbox" value="sport" name="interest">运动
        <input type="checkbox" value="music" name="interest">音乐
    </p>
    <p>按钮:
        <input type="button" value="不知道有啥用" name="btn">按钮
    </p>
    <p>图片按钮:
        <input type="image" src="../resources/image/23130291.jpg" name="pic">
    </p>
    <p>文件按钮:
        <input type="file" name="file">
    </p>
    <p>隐形按钮:
        <input name="hidden" type="hidden" value="123456">
    </p>
    <p>
        <input type="submit">
        <input type="reset">
    </p>
</form>
</body>
</html>
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号