选中复选框,即使我将其设置为禁用 [英] Checking the checkbox even I set it into disabled
本文介绍了选中复选框,即使我将其设置为禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的脚本
禁用由php代码设置的复选框
while($ row = $ result1-> fetch_assoc ){
< td>< input name =checkbox []type =checkboxid =checkbox []value ='。$ row ['id']。''。 $ row ['pr'] ==?disabled:)。'class =checkbox>< / td&
}
这里是我的脚本检查所有
function setCheckboxes3(act){
var e = document.getElementsByClassName('checkbox');
var elts_cnt =(typeof(e.length)!='undefined')? e.length:0;
if(!elts_cnt){
return;
}
for(var i = 0; i e [i] .checked =(act == 1 || act == 0)? act:(e [i] .checked?0:1);
}
}
链接
a href =javascript:setCheckboxes3(1); class =chkmenu>全部检查< / a> | < a href =javascript:setCheckboxes3(0); class =chkmenu>取消选中所有< / a>
解决方案
更新要传递的链接 true | false
< a href =javascript:setCheckboxes3(true); class =chkmenu>全部检查< / a> | < a href =javascript:setCheckboxes3(false); class =chkmenu>取消选中所有< / a>
然后
function setCheckboxes3(act){
$('。checkbox')。not(':disabled')prop('checked',act)
//或$ :not(:disabled)')。prop('checked',act)
}
与您当前的链接
function setCheckboxes3(act){
$(' :disabled')。prop('checked',act == 1?true:false);
//或$('。checkbox:not(:disabled)')。prop('checked',act == 1?true:false)
}
Why even I set the checkbox into disable it always check all when I click the script of check all.
Here's my script
Disable checkbox set by php code
while ($row = $result1->fetch_assoc()) {
<td><input name="checkbox[]" type="checkbox" id="checkbox[]" value="' . $row['id'] . '"'.($row['pr'] == ""?"disabled ":"").' class="checkbox"></td>
}
And here's my script on check all
function setCheckboxes3(act) {
var e = document.getElementsByClassName('checkbox');
var elts_cnt = (typeof(e.length) != 'undefined') ? e.length : 0;
if (!elts_cnt) {
return;
}
for (var i = 0; i < elts_cnt; i++) {
e[i].checked = (act == 1 || act == 0) ? act : (e[i].checked ? 0 : 1);
}
}
Links
a href="javascript:setCheckboxes3(1);" class="chkmenu">Check All</a> | <a href="javascript:setCheckboxes3(0);" class="chkmenu">Uncheck All</a>
解决方案
Update the links to pass true|false
<a href="javascript:setCheckboxes3(true);" class="chkmenu">Check All</a> | <a href="javascript:setCheckboxes3(false);" class="chkmenu">Uncheck All</a>
then
function setCheckboxes3(act) {
$('.checkbox').not(':disabled').prop('checked', act)
//or $('.checkbox:not(:disabled)').prop('checked', act)
}
with your current links
function setCheckboxes3(act) {
$('.checkbox').not(':disabled').prop('checked', act == 1 ? true : false);
//or $('.checkbox:not(:disabled)').prop('checked', act == 1 ? true : false)
}
这篇关于选中复选框,即使我将其设置为禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文