[LON-CAPA-cvs] cvs: loncom /homework edit.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 30 Apr 2003 19:40:47 -0000


matthew		Wed Apr 30 15:40:47 2003 EDT

  Modified files:              
    /loncom/homework	edit.pm 
  Log:
  Added &html_element_name() to return a name for new elements.  This makes
  it easier for those of us who are forced to write javascript to reference
  elements on the edit page.
  
  
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.46 loncom/homework/edit.pm:1.47
--- loncom/homework/edit.pm:1.46	Thu Feb 13 18:53:33 2003
+++ loncom/homework/edit.pm	Wed Apr 30 15:40:47 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.46 2003/02/13 23:53:33 albertel Exp $
+# $Id: edit.pm,v 1.47 2003/04/30 19:40:47 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -481,12 +481,17 @@
   return $result;
 }
 
+sub html_element_name {
+    my ($name) = @_;
+    return $Apache::lonxml::curdepth.'.'.$name;
+}
+
 sub text_arg {
   my ($description,$name,$token,$size) = @_;
   my $result;
   if (!defined $size) { $size=20; }
   my $arg=$token->[2]{$name};
-  $result=$description.'&nbsp;<input name="'."$Apache::lonxml::curdepth.$name".
+  $result=$description.'&nbsp;<input name="'.&html_element_name($name).
     '" type="text" value="'.$arg.'" size="'.$size.'" />';
   return $result;
 }
@@ -510,8 +515,8 @@
 	    $optionlist.="<option $value >$option</option>\n";
 	}
     }
-    $result.=$description.'&nbsp;<select name="'.
-	"$Apache::lonxml::curdepth.$name".'">
+    $result.=$description.'&nbsp;<select name="'.&html_element_name($name).
+        '">
        '.$optionlist.'
       </select>';
     return $result;
@@ -540,7 +545,8 @@
     }
     $optionlist.="<option value=\"TYPEDINVALUE\">Type in value</option>\n";
     if (($found) || (!$selected)) {
-	$result.=$description.'&nbsp;<select name="'."$Apache::lonxml::curdepth.$name".'">
+	$result.=$description.'&nbsp;<select name="'.&html_element_name($name)
+            .'">
        '.$optionlist.'
       </select>';
     } else {