嗨,我刚刚创建了一个包含一些值的表。我想用第一个复选框选择所有复选框并取消选中它们。print "内容类型: 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 => '表', -b