繁体   English   中英

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

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

当用户尝试从复选框组中选择四个以上的值(复选框名称位于数组中)时,我想显示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>

这是jQuery版本:

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

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM