简体   繁体   English

当数据来自数据库时,如何从一组复选框中仅选择4个

[英]How we can choose only 4 from a group of checkbox when the data is coming from the database

I want to show JavaScript alert when user trying to choose more than four values from the group of checkbox the checkbox names are in array 当用户尝试从复选框组中选择四个以上的值(复选框名称位于数组中)时,我想显示JavaScript警报

<div class="checkbox alert alert-primary">

    <p><input type="checkbox" id="calorieCheckbox" name="txt_tradesman[]" value="<?php echo $restrad['tradesman_id'] ?>" onClick="return KeepCount()"><?php echo $restrad['fullname'] ?> <p>    

</div>

Here's jQuery version: 这是jQuery版本:

$('[name="txt_tradesman[]"]:checked').length $('[[name =“ txt_tradesman []”]:checked')。length

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当数据来自数据库时,如何检查html表中的CheckBox? 在asp.net MVC中 - How to Check CheckBox in html table when data is coming from Database? in asp.net MVC 当数据来自数据库时,如何仅选择一个复选框 - How to select only one checkbox when data comes from database 当数据动态来自数据库时,如何从对象数组中解构? - how can I destructure from an array of objects when data is coming from database dynamically? 如何过滤来自 Firestore 数据库的数据 - How to Filter Data coming from Firestore Database 当我从模态中选择 YES 选项时如何取消选中复选框? - How to Uncheck checkbox when i choose YES option from modal? 当复选框名称来自php中的数据库时,如何访问多个复选框名称 - how to access multiple checkboxes names while checkbox name is coming from database in php 根据我们通过按钮选择的行从数据库设置值 - Set value from database based on row we choose by button 当我们从Word文件中粘贴文本时,如何删除来自FCKEditor的弹出消息 - How to remove the Pop up message coming from FCKEditor when we paste text from a word file 从数据库中检索数据并在获得定界符时将数据分开? - Retrieve data from a database and separate the data when we get a delimiter? 当值与来自 database-javascript 的数据相同时选中复选框 - checkbox checked when value same with data from database-javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM