[LON-CAPA-cvs] cvs: loncom(version_2_8_X) /interface loncommon.pm

raeburn raeburn@source.lon-capa.org
Wed, 28 Oct 2009 17:24:33 -0000


raeburn		Wed Oct 28 17:24:33 2009 EDT

  Modified files:              (Branch: version_2_8_X)
    /loncom/interface	loncommon.pm 
  Log:
  - Backport 1.872, 1.874.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.692.2.12 loncom/interface/loncommon.pm:1.692.2.13
--- loncom/interface/loncommon.pm:1.692.2.12	Mon Jan 12 04:39:30 2009
+++ loncom/interface/loncommon.pm	Wed Oct 28 17:24:32 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.692.2.12 2009/01/12 04:39:30 raeburn Exp $
+# $Id: loncommon.pm,v 1.692.2.13 2009/10/28 17:24:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1746,7 +1746,7 @@
 
 =pod
 
-=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc)
+=item * &select_dom_form($defdom,$name,$includeempty,$showdomdesc,$change)
 
 Returns a string containing a <select name='$name' size='1'> form to 
 allow a user to select the domain to preform an operation in.  
@@ -1755,16 +1755,21 @@
 If the $includeempty flag is set, it also includes an empty choice ("no domain
 selected");
 
-If the $showdomdesc flag is set, the domain name is followed by the domain description. 
+If the $showdomdesc flag is set, the domain name is followed by the domain description.
+
+The optional $onchange argument specifies what should occur if the domain selector is changed, e.g., 'this.form.submit()' if the form is to be automatically submitted.
 
 =cut
 
 #-------------------------------------------
 sub select_dom_form {
-    my ($defdom,$name,$includeempty,$showdomdesc) = @_;
+    my ($defdom,$name,$includeempty,$showdomdesc,$onchange) = @_;
+    if ($onchange) {
+        $onchange = ' onchange="'.$onchange.'"';
+    }
     my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
     if ($includeempty) { @domains=('',@domains); }
-    my $selectdomain = "<select name=\"$name\" size=\"1\">\n";
+    my $selectdomain = "<select name=\"$name\" size=\"1\"$onchange>\n";
     foreach my $dom (@domains) {
         $selectdomain.="<option value=\"$dom\" ".
             ($dom eq $defdom ? 'selected="selected" ' : '').'>'.$dom;