summaryrefslogtreecommitdiff
path: root/httemplate/elements/checkboxes-table-name.html
diff options
context:
space:
mode:
authorivan <ivan>2008-08-24 22:35:14 +0000
committerivan <ivan>2008-08-24 22:35:14 +0000
commitffb62662ca2b28fd913ca2cffef595cc35c0a52b (patch)
tree4093b76d39acf8aa570aeb67a614436f5b1e366f /httemplate/elements/checkboxes-table-name.html
parent6f07c574d3c6732a6f90f73bf5dcb6732c5a94d4 (diff)
add controls to select/unselect/toggle all checkboxes
Diffstat (limited to 'httemplate/elements/checkboxes-table-name.html')
-rw-r--r--httemplate/elements/checkboxes-table-name.html37
1 files changed, 36 insertions, 1 deletions
diff --git a/httemplate/elements/checkboxes-table-name.html b/httemplate/elements/checkboxes-table-name.html
index 1638b9ca2..b236787b6 100644
--- a/httemplate/elements/checkboxes-table-name.html
+++ b/httemplate/elements/checkboxes-table-name.html
@@ -43,6 +43,15 @@ Example:
<TABLE CELLSPACING=0 CELLPADDING=0>
+<TR>
+ <TD COLSPAN=2 ALIGN="center"><FONT SIZE="-1">(
+ <A HREF="javascript:setAll<%$prefix%>(true)">select all</A> |
+ <A HREF="javascript:setAll<%$prefix%>(false)">unselect all</A> |
+ <A HREF="javascript:toggleAll<%$prefix%>()">toggle all</A>
+ )</FONT></TD>
+</TR>
+
+% my $num=0;
% foreach my $item ( @{ $opt{'names_list'} } ) {
%
% my $name = ref($item) ? $item->[0] : $item;
@@ -72,7 +81,7 @@ Example:
<TR>
<TD VALIGN="top">
- <INPUT TYPE="checkbox" NAME="<% $opt{'link_table'}. ".$name" %>" <% $checked %> VALUE="ON">
+ <INPUT TYPE="checkbox" NAME="<% $opt{'link_table'}. ".$name" %>" <% $checked %> ID="<%$prefix.$num++%>" VALUE="ON">
</TD>
<TD><% $display %>
% if ( $desc ) {
@@ -85,10 +94,36 @@ Example:
</TABLE>
+<SCRIPT TYPE="text/javascript">
+
+ function setAll<%$prefix%>(setTo) {
+% for ( 0 .. ($num-1) ) {
+ document.getElementById('<%$prefix.$_%>').checked = setTo;
+% }
+ }
+
+ function toggleAll<%$prefix%>(setTo) {
+% for ( 0 .. ($num-1) ) {
+ var element = document.getElementById('<%$prefix.$_%>');
+ if ( element.checked == true ) {
+ element.checked = false;
+ } else {
+ element.checked = true;
+ }
+% }
+ }
+
+</SCRIPT>
+
<%init>
my( %opt ) = @_;
+my @pset = ( 'a'..'z', 'A'..'Z', '0'..'9' );
+
+my $prefix = $opt{prefix}
+ || join('', map $pset[ int(rand $#pset) ], (0..20) );
+
my( $source_pkey, $sourcenum, $source_obj );
if ( $opt{'source_obj'} ) {