]> git.mjollnir.org Git - moodle.git/commitdiff
Update to static JS - 'hitem' hidden fields now optional for lockoptions.
authorsam_marshall <sam_marshall>
Wed, 20 Sep 2006 15:04:57 +0000 (15:04 +0000)
committersam_marshall <sam_marshall>
Wed, 20 Sep 2006 15:04:57 +0000 (15:04 +0000)
lib/javascript-static.js

index f49b93bf3e813815e46409973406f56687ee206f..e63a3823564c660e58667606f15f6f6983118929 100644 (file)
@@ -42,10 +42,10 @@ function checknone() {
 }
 
 function lockoptions(form, master, subitems) {
-  // subitems is an array of names of sub items
-  // requires that each item in subitems has a
+  // Subitems is an array of names of sub items.
+  // Optionally, each item in subitems may have a
   // companion hidden item in the form with the
-  // same name but prefixed by "h"
+  // same name but prefixed by "h".
   if (eval("document."+form+"."+master+".checked")) {
     for (i=0; i<subitems.length; i++) {
       unlockoption(form, subitems[i]);
@@ -60,12 +60,16 @@ function lockoptions(form, master, subitems) {
 
 function lockoption(form,item) {
   eval("document."+form+"."+item+".disabled=true");/* IE thing */
-  eval("document."+form+".h"+item+".value=1");
+  if(document.forms[form].elements['h'+item]) {
+    eval("document."+form+".h"+item+".value=1");
+  }
 }
 
 function unlockoption(form,item) {
   eval("document."+form+"."+item+".disabled=false");/* IE thing */
-  eval("document."+form+".h"+item+".value=0");
+  if(document.forms[form].elements['h'+item]) {
+    eval("document."+form+".h"+item+".value=0");
+  }
 }
 
 function submitFormById(id) {