前端学习之HTML——(5)

1、表单与提交

        什么是表单?

        例如一个网站中登录页面,需要输入用户名和密码,这就是一个表单。而我们常用post和get来提交表单

        表单对应的标签为form,其中method和action为标签必填的内容,前者表示如何发生表单(post?get?),后者为向何处发送表单。

        

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录注册</title>
</head>
<body>
    <h1>注册</h1>
    <!--input 文本输入框-->
    <form action="我的第一个网页.html" method="get">
        <p>用户名:<input type="text" name="username"></p>
        <p>密码:<input type="password" name="pwd"></p>
        <p>
        <input type="submit">
        <input type="reset">
        </p>
        
    </form>
</body>
</html>

可以看到,使用get方式时,内容会在url中呈现但使用post时ulr中便不会呈现提交内容

 

2、按钮与多选框

        前面的input中的属性有以下几种

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录注册</title>
</head>
<body>
    <h1>注册</h1>
    <!--input 文本输入框-->
    <form action="我的第一个网页.html" method="post">
        <p>用户名:<input type="text" name="username"></p>
        <p>密码:<input type="password" name="pwd"></p>
        <p>
        <input type="submit">
        <input type="reset">
        </p>
        <!--单选-->
        <p>
            性别:
            <input type="radio" value="boy" name="sex">男
            <input type="radio" value="girl" name="sex">女
        </p>
        <!--多选框-->
        <p>
            爱好:
            <input type="checkbox" value="A" name="hobby">A
            <input type="checkbox" value="B" name="hpbby">B
            <input type="checkbox" value="C" name="hobby">C
        </p>
        <!--按钮-->
        <p>
            按钮:
            <input type="button" name="btn1" value="点击">
            <input type="image" src="resources/img/test.jpg">
        </p>
    </form>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值