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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Mon, 05 May 2003 15:17:25 -0000


bowersj2		Mon May  5 11:17:25 2003 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  When more then two elements that have a "checkall" button are in the 
  same state, the "check all" buttons should only apply to the particular
  *element* they are clicking the "Check All" button for, not all 
  check boxes on the screen.
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.17 loncom/interface/lonhelper.pm:1.18
--- loncom/interface/lonhelper.pm:1.17	Fri May  2 15:20:51 2003
+++ loncom/interface/lonhelper.pm	Mon May  5 11:17:25 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.17 2003/05/02 19:20:51 bowersj2 Exp $
+# $Id: lonhelper.pm,v 1.18 2003/05/05 15:17:25 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -997,17 +997,20 @@
     if ($self->{'multichoice'}) {
         $result .= <<SCRIPT;
 <script>
-    function checkall(value) {
+    function checkall(value, checkName) {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
-            document.forms.helpform.elements[i].checked=value;
+            ele = document.forms.helpform.elements[i];
+            if (ele.name == checkName + '.forminput') {
+                document.forms.helpform.elements[i].checked=value;
+            }
         }
     }
 </script>
 SCRIPT
         $buttons = <<BUTTONS;
 <br />
-<input type="button" onclick="checkall(true)" value="Select All" />
-<input type="button" onclick="checkall(false)" value="Unselect All" />
+<input type="button" onclick="checkall(true, '$var')" value="Select All" />
+<input type="button" onclick="checkall(false, '$var')" value="Unselect All" />
 <br />&nbsp;
 BUTTONS
     }
@@ -1474,10 +1477,10 @@
     if ($self->{'multichoice'}) {
         $result = <<SCRIPT;
 <script>
-    function checkall(value) {
+    function checkall(value, checkName) {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
             ele = document.forms.helpform.elements[i];
-            if (ele.type == "checkbox") {
+            if (ele.name == checkName + '.forminput') {
                 document.forms.helpform.elements[i].checked=value;
             }
         }
@@ -1486,8 +1489,8 @@
 SCRIPT
         $buttons = <<BUTTONS;
 <br /> &nbsp;
-<input type="button" onclick="checkall(true)" value="Select All" />
-<input type="button" onclick="checkall(false)" value="Unselect All" />
+<input type="button" onclick="checkall(true, '$var')" value="Select All Resources" />
+<input type="button" onclick="checkall(false, '$var')" value="Unselect All Resources" />
 <br /> &nbsp;
 BUTTONS
     }
@@ -1627,21 +1630,25 @@
     my $self = shift;
     my $result = '';
     my $buttons = '';
+    my $var = $self->{'variable'};
 
     if ($self->{'multichoice'}) {
         $result = <<SCRIPT;
 <script>
-    function checkall(value) {
+    function checkall(value, checkName) {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
-            document.forms.helpform.elements[i].checked=value;
+            ele = document.forms.helpform.elements[i];
+            if (ele.name == checkName + '.forminput') {
+                document.forms.helpform.elements[i].checked=value;
+            }
         }
     }
 </script>
 SCRIPT
         $buttons = <<BUTTONS;
 <br />
-<input type="button" onclick="checkall(true)" value="Select All" />
-<input type="button" onclick="checkall(false)" value="Unselect All" />
+<input type="button" onclick="checkall(true, '$var')" value="Select All Students" />
+<input type="button" onclick="checkall(false, '$var')" value="Unselect All Students" />
 <br />
 BUTTONS
     }
@@ -1832,10 +1839,10 @@
     if ($self->{'multichoice'}) {
         $result = <<SCRIPT;
 <script>
-    function checkall(value) {
+    function checkall(value, checkName) {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
             ele = document.forms.helpform.elements[i];
-            if (ele.type == "checkbox") {
+            if (ele.name == checkName + '.forminput') {
                 document.forms.helpform.elements[i].checked=value;
             }
         }
@@ -1844,8 +1851,8 @@
 SCRIPT
         $buttons = <<BUTTONS;
 <br /> &nbsp;
-<input type="button" onclick="checkall(true)" value="Select All" />
-<input type="button" onclick="checkall(false)" value="Unselect All" />
+<input type="button" onclick="checkall(true, '$var')" value="Select All Files" />
+<input type="button" onclick="checkall(false, '$var')" value="Unselect All Files" />
 <br /> &nbsp;
 BUTTONS
     }