Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取选中[ALL]或未选中框jquery的值_Jquery - Fatal编程技术网

获取选中[ALL]或未选中框jquery的值

获取选中[ALL]或未选中框jquery的值,jquery,Jquery,我读过这个 现在还不清楚您是想在客户端还是服务器端执行。无论如何,这是一个JQuery代码段,它用所有选中的复选框填充数组: var checkedCheckboxes = new Array(); $('input:checkbox[name="checkGroup"]').each(function(index) { if ($(this).attr('checked') == 'true') { checkedCeckboxes.push(this);} }); 现在还不清楚您是想

我读过这个


现在还不清楚您是想在客户端还是服务器端执行。无论如何,这是一个JQuery代码段,它用所有选中的复选框填充数组:

var checkedCheckboxes = new Array();
$('input:checkbox[name="checkGroup"]').each(function(index) {
  if ($(this).attr('checked') == 'true') { checkedCeckboxes.push(this);}
});

现在还不清楚您是想在客户端还是服务器端执行。无论如何,这是一个JQuery代码段,它用所有选中的复选框填充数组:

var checkedCheckboxes = new Array();
$('input:checkbox[name="checkGroup"]').each(function(index) {
  if ($(this).attr('checked') == 'true') { checkedCeckboxes.push(this);}
});
尝试:

函数getChecked()
{
变量数组;
var加法;
var计数=0;
for(var k=1;k
并使用gollowing html代码:

<form id='boxes' name='boxes'>
    <input name='list' type='checkbox' id='checkbox' value='1'>
    <input name='list' type='checkbox' id='checkbox' value='2'>
    <input name='list' type='checkbox' id='checkbox' value='3'>
    <input name='list' type='checkbox' id='checkbox' value='4'>
</form>

等等…

试试:

函数getChecked()
{
变量数组;
var加法;
var计数=0;
for(var k=1;k
并使用gollowing html代码:

<form id='boxes' name='boxes'>
    <input name='list' type='checkbox' id='checkbox' value='1'>
    <input name='list' type='checkbox' id='checkbox' value='2'>
    <input name='list' type='checkbox' id='checkbox' value='3'>
    <input name='list' type='checkbox' id='checkbox' value='4'>
</form>


等等…

数组、加法和计数变量只是我自己代码中的一部分,如果需要,可以删除它。数组、加法和计数变量只是我自己代码中的一部分,如果需要,可以删除它。
function getChecked ()
{
    var array;
    var addition;
    var count = 0;
    for (var k = 1; k < document.getElementById('boxes').elements.length; k++)
    {
         if (document.getElementById('boxes').elements[k].checked == true)
         {
             addition = k + '';
             array = array + '_' + addition;
             count = count + 1;
         }
    }
}
<form id='boxes' name='boxes'>
    <input name='list' type='checkbox' id='checkbox' value='1'>
    <input name='list' type='checkbox' id='checkbox' value='2'>
    <input name='list' type='checkbox' id='checkbox' value='3'>
    <input name='list' type='checkbox' id='checkbox' value='4'>
</form>