[freeside-commits] freeside/httemplate/elements checkboxes-table-name.html, 1.3, 1.4
Ivan,,,
ivan at wavetail.420.am
Sun Aug 24 15:35:17 PDT 2008
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv24657
Modified Files:
checkboxes-table-name.html
Log Message:
add controls to select/unselect/toggle all checkboxes
Index: checkboxes-table-name.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/checkboxes-table-name.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- checkboxes-table-name.html 1 Aug 2007 22:25:08 -0000 1.3
+++ checkboxes-table-name.html 24 Aug 2008 22:35:14 -0000 1.4
@@ -43,6 +43,15 @@
<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 @@
<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 @@
</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'} ) {
More information about the freeside-commits
mailing list