mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
adding lockoptions functionality to formslib library and added lockoptionsall() function which allows multiple dependencies for one dependent element and handles that properly.
This commit is contained in:
parent
c70095e440
commit
50ef8eb9bd
2 changed files with 71 additions and 5 deletions
|
@ -58,6 +58,35 @@ function lockoptions(form, master, subitems) {
|
|||
return(true);
|
||||
}
|
||||
|
||||
function lockoptionsall(formid) {
|
||||
var lock=new Object();
|
||||
var items=eval(formid+'items');
|
||||
var form=document.forms[formid];
|
||||
for (var master in items){
|
||||
var subitems=items[master].dependents;
|
||||
var thislock;
|
||||
if (items[master].condition=='checked'){
|
||||
thislock=!form.elements[master].checked;
|
||||
}else{
|
||||
thislock=!(form.elements[master].value==items[master].condition);
|
||||
}
|
||||
|
||||
for (var i=0; i<subitems.length; i++) {
|
||||
if (lock[subitems[i]]!=null){
|
||||
lock[subitems[i]] = thislock || lock[subitems[i]];
|
||||
}else{
|
||||
lock[subitems[i]] = thislock;
|
||||
}
|
||||
}
|
||||
|
||||
for (var item in lock) {
|
||||
form.elements[item].disabled=lock[item];
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
function lockoption(form,item) {
|
||||
eval("document."+form+"."+item+".disabled=true");/* IE thing */
|
||||
if(document.forms[form].elements['h'+item]) {
|
||||
|
@ -115,7 +144,7 @@ function confirm_if(expr, message) {
|
|||
|
||||
/*
|
||||
findParentNode (start, elementName, elementClass, elementID)
|
||||
|
||||
|
||||
Travels up the DOM hierarchy to find a parent element with the
|
||||
specified tag name, class, and id. All conditions must be met,
|
||||
but any can be ommitted. Returns the BODY element if no match
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue