Home > Web Front-end > JS Tutorial > How to achieve all selection and none selection in phpcms background? (Code attached)

How to achieve all selection and none selection in phpcms background? (Code attached)

不言
Release: 2018-08-22 16:53:21
Original
1951 people have browsed it

The content of this article is about how to implement all selection and none selection in phpcms background? (Attached code), it has certain reference value, friends in need can refer to it, I hope it will be helpful to you .

html code

//标题里面的复选框
<th width="5%"><input value="" id="check_box" onclick="selectallForAuditions(&#39;ids[]&#39;);" type="checkbox"/></th>

//值里面的复选框
<td align="center">
    <input id="course_<?php echo $r[&#39;id&#39;]; ?>" class="inputcheckbox" onclick="chooseCourse(<?php echo $r[&#39;id&#39;]; ?>)" name="ids[]" value="<?php echo $r[&#39;id&#39;]; ?>" type="checkbox">
</td>
Copy after login

jquery code

function selectallForAuditions(name) {
    if ($("#check_box").attr("checked")==&#39;checked&#39;) {
        $("input[name=&#39;"+name+"&#39;]").each(function() {
            //全选jq代码
            $(this).prop("checked","checked");
            chooseAllCourse($(this).val());
        });
    } else {
        $("input[name=&#39;"+name+"&#39;]").each(function() {
            //都不选jq的代码
            $(this).removeAttr("checked");
        });
    }
}


//全选课程
    function chooseAllCourse(courseId) {
        var strKeyName = auditions + "_courseId_" + courseId;
        localStorage.setItem(strKeyName, courseId);
        getCourse();
    }
Copy after login

Related recommendations:

phpcms always jumps to install/install after the installation is completed. php, phpcms installation

PHPCMS builds wap mobile website, phpcms builds wap

The above is the detailed content of How to achieve all selection and none selection in phpcms background? (Code attached). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template