--- loncom/interface/lonuserutils.pm	2014/04/16 12:17:12	1.167
+++ loncom/interface/lonuserutils.pm	2014/12/15 01:11:49	1.169
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.167 2014/04/16 12:17:12 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.169 2014/12/15 01:11:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5267,7 +5267,7 @@ sub set_login {
 sub course_sections {
     my ($sections_count,$role,$current_sec) = @_;
     my $output = '';
-    my @sections = (sort {$a <=> $b} keys %{$sections_count});
+    my @sections = (sort {$a <=> $b} keys(%{$sections_count}));
     my $numsec = scalar(@sections);
     my $is_selected = ' selected="selected"';
     if ($numsec <= 1) {
@@ -5396,6 +5396,9 @@ function setSections(formname,crstype) {
     var groups = new Array($groupslist);
     for (var i=0;i<formname.elements.length;i++) {
         var str = formname.elements[i].name;
+        if (typeof(str) === "undefined") {
+            continue;
+        }
         var checkcurr = str.match(re1);
         if (checkcurr != null) {
             var num = i;