[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 05 May 2004 14:12:54 -0000


matthew		Wed May  5 10:12:54 2004 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm 
  Log:
  Modified &checkbox to take a $checked parameter and to use $value as the
  value used in the form element instead of taking it to indicate checkedness.
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.67 loncom/interface/lonhtmlcommon.pm:1.68
--- loncom/interface/lonhtmlcommon.pm:1.67	Fri Apr 23 13:49:25 2004
+++ loncom/interface/lonhtmlcommon.pm	Wed May  5 10:12:54 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.67 2004/04/23 17:49:25 matthew Exp $
+# $Id: lonhtmlcommon.pm,v 1.68 2004/05/05 14:12:54 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -163,9 +163,15 @@
 ##############################################
 ##############################################
 sub checkbox {
-    my ($name,$value) = @_;
-    my $Str = '<input type="checkbox" name="'.$name.'"'.
-	($value?' checked="1"':'').' />';
+    my ($name,$checked,$value) = @_;
+    my $Str = '<input type="checkbox" name="'.$name.'" ';
+    if (defined($value)) {
+        $Str .= 'value="'.$value.'"';
+    } 
+    if ($checked) {
+        $Str .= ' checked="1"';
+    }
+    $Str .= ' />';
     return $Str;
 }