簡體   English   中英

復選框表以選擇行

[英]Checkbox table to select rows

嗨,我剛剛創建了一些值的表。 我想選中帶有第一個復選框的所有復選框,然后取消選中它們。 打印“內容類型:text / html; charset = iso-8859-1 \\ n \\ n”;

my $script = qq{
\$('#id').change(function() {
var checkboxes = \$(this).closest('form').find(':checkbox');
if(\$(this).is(':checked')) {
    checkboxes.attr('checked', 'checked');
} else {
    checkboxes.removeAttr('checked');
}

}); };

use CGI::Carp qw(fatalsToBrowser);

$q = new CGI;
print $q->start_html(
-title=>"Read a File",
-style  => {-src =>'css/ui-lightness/jquery-ui-1.10.3.custom.css" rel="stylesheet'},
     -script => [
        {-src =>'js/jquery-1.9.1.js'}, 
        {-src =>'js/jquery-ui-1.10.3.custom.js'

        }, 
      ],   
);

my @aRows = ();

my $oCheckAll = $q->input({-type => 'checkbox', -name => 'sel_all', -id =>'id' }, 'Select All');

# Add header of table
push @aRows, (
   $q->Tr($q->th([$oCheckAll, 'Name', 'Surname', 'DB'])),   
);

# Add table rows
for(my $i=0; $i<4; $i++) {
   push @aRows, (
      $q->Tr($q->td([$q->input({-type => 'checkbox' -id => 'id'}), "EMR", "MB", $i]))
   );
}

print $q->style(".table th, td { width: 25%;}");

print $q->tabl

e({-class =>'table',-b

$('input:checkbox').change(function (){
    var thisCheck = $(this);
    if (thischeck.is(':checked')){
        thisCheck.parent().children('input:checkbox').attr('checked','checked');
    }
});

希望這可以幫助 !!!

我認為這是此變體中的錯誤:

$('table tr td:first-child input').click(function(event){
  $(this).parent().parent().find("td input").attr("checked", $(this).is(":checked"));
});  

請參閱鏈接。

$('table tr td:first-child input').click(function(event){
  if ($(this).is(':checked')) {
    $(this).parent().parent().find("td input:not(:checked)").click();
  } else {
    $(this).parent().parent().find("td input:checked").click();
  }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM