search
Homephp教程PHP源码获取单个checkbox选中项(三种写法)

跳至 [1] [全屏预览]
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>云视频登陆</title>
    <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css">
    <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>


<div data-role="page">
    <div data-role="header">
        <h1 id="欢迎访问我的主页">欢迎访问我的主页</h1>
    </div>

    <div data-role="main" class="ui-content">
        <a href="#myPopup" data-rel="popup" data-position-to="window"
           class="ui-btn ui-btn-inline ui-corner-all ui-icon-check ui-btn-icon-left">弹窗中使用表单</a>

        <div data-role="popup" id="myPopup" class="ui-content" style="min-width:250px;">
            <form method="post" action="do.php">
                <div>
                    <h3 id="登录信息">登录信息</h3>
                    <label for="user" class="ui-hidden-accessible">用户名:</label>
                    <input type="text" name="user" id="user" placeholder="家长姓名" data-clear-btn="true">
                    <label for="telphone" class="ui-hidden-accessible">手机号</label>
                    <input type="tel" name="tel" id="telphone" placeholder="手机号" data-clear-btn="true">
                    <label for="loginstatus">保存登录</label>
                    <input type="checkbox" name="loginstatus" id="loginstatus" value="1"  data-mini="true">

                    <input type="button" id="login" data-inline="true" value="登录">
                </div>
            </form>
        </div>
    </div>

    <div data-role="footer">
        <h1 id="底部文本">底部文本</h1>
    </div>
</div>


<script>


    $("#login").click(function () {
        var user = $("#user").val();
        var telphone = $("#telphone").val();
     //获取复选框是否被选中的方法
        //$("input:[type='checkbox']:checked").val();
        //$("input[name='ck']:checked").val();
        var  loginstatus =$("input[type='checkbox']:checked").val();
      //  var  loginstatus = $("input[name='loginstatus']:checked").val();

       //var  loginstatus =  $("input:checkbox:checked").val();
        $.ajax({
            type: "POST",
            url: "do.php",
            data: "name=" + user + "&tel=" + telphone + "&loginstatus="+loginstatus,
            success: function (data) {
                alert("成功返回数据: " + data);
            }
        });

    });


</script>


</body>
</html>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software