input checkbox復選框取值


    <table>
        <!--列表表頭 開始 -->
        <tr class="ui-widget ui-state-hover" style="height: 36px;">
            <th><input type="checkbox" name="checkbox" id="checkAll"/></th>
        </tr>
        <c:forEach var="li" items="${resultList}" varStatus="status">
            <tr>
               <td>
                    <input type="checkbox" name="checkedId" value="${li.extProjectId}" id="${li.extProjectId}"/>
                </td>         
            </tr>
        </c:forEach>
    </table>
var checkRows = function () {
    var rows = document.getElementsByName("checkedId");
    var checkAll = document.getElementById("checkAll");
    var checkedRows = '';
    for (var i = 0; i < rows.length; i++) {
        if (checkAll.checked == true) {
            rows[i].checked = true;
            if (checkedRows.length > 0) {
                checkedRows += ",";
            }
            checkedRows += rows[i].value;
        }else {
            if (rows[i].checked) {
                if (checkedRows.length > 0) {
                    checkedRows += ",";
                }
                checkedRows += rows[i].value;
            }
        }
    }
    return checkedRows;
}
function checkAll(checkChildName, checkParentId) {
var child = document.getElementsByName(checkChildName);
var checkall = document.getElementById(checkParentId);
for ( var i = 0; i < child.length; i++) {
if (checkall.checked == true) {
child[i].checked = true;
} else {
child[i].checked = false;
}
}
}
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM