summaryrefslogtreecommitdiff
path: root/httemplate/elements/checkboxes-table-name.html
diff options
context:
space:
mode:
authorivan <ivan>2009-01-05 00:26:54 +0000
committerivan <ivan>2009-01-05 00:26:54 +0000
commit125fb1a284ae96b46fe433c418aafa87862c4382 (patch)
treecb9485c9cfd7e685bc63ea40fe214f80c18407b1 /httemplate/elements/checkboxes-table-name.html
parentc23d6e1673dbec98fe9d778ee55962d2cbd145d5 (diff)
add rate copying, RT#4431
Diffstat (limited to 'httemplate/elements/checkboxes-table-name.html')
-rw-r--r--httemplate/elements/checkboxes-table-name.html88
1 files changed, 15 insertions, 73 deletions
diff --git a/httemplate/elements/checkboxes-table-name.html b/httemplate/elements/checkboxes-table-name.html
index b236787b6..31652f330 100644
--- a/httemplate/elements/checkboxes-table-name.html
+++ b/httemplate/elements/checkboxes-table-name.html
@@ -41,79 +41,12 @@ Example:
</%doc>
-<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;
-% ( my $display = $name ) =~ s/ /&nbsp;/g;
-% $display .= $item->[1]{note} if ref($item) && $item->[1]{note};
-% my $desc = ref($item) && $item->[1]{desc} ? $item->[1]{desc} : '';
-%
-% my $checked;
-% if ( $cgi->param('error') ) {
-%
-% $checked = $cgi->param($opt{'link_table'}. ".$name" )
-% ? 'CHECKED'
-% : '';
-%
-% } else {
-%
-% $checked =
-% qsearchs( $opt{'link_table'}, {
-% $source_pkey => $sourcenum,
-% $opt{'name_col'} => $name,
-% %$link_static,
-% } )
-% ? 'CHECKED'
-% : ''
-%
-% }
-
- <TR>
- <TD VALIGN="top">
- <INPUT TYPE="checkbox" NAME="<% $opt{'link_table'}. ".$name" %>" <% $checked %> ID="<%$prefix.$num++%>" VALUE="ON">
- </TD>
- <TD><% $display %>
-% if ( $desc ) {
- <BR><FONT SIZE="-2"><% $desc %></FONT>
-% }
- </TD>
- </TR>
-
-% }
-
-</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>
+<% include('checkboxes.html',
+ 'names_list' => $opt{'names_list'},
+ 'checked_callback' => $checked_callback,
+ 'element_name_prefix' => $opt{'link_table'}. '.',
+ )
+%>
<%init>
@@ -145,4 +78,13 @@ $source_pkey = $opt{'num_col'} || $source_pkey;
my $link_static = $opt{'link_static'} || {};
+my $checked_callback = sub {
+ my( $cgi, $name ) = @_;
+ qsearchs( $opt{'link_table'}, {
+ $source_pkey => $sourcenum,
+ $opt{'name_col'} => $name,
+ %$link_static,
+ });
+};
+
</%init>