Bläddra i källkod

Adding updateSelect function taking the input element, list of cells with buttons, the value of the input and the label of the button as inputs and outcome is the changed value of the input and color applied to selected buttons

Andrej Studen 1 år sedan
förälder
incheckning
77d15c6f6c
1 ändrade filer med 25 tillägg och 1 borttagningar
  1. 25 1
      web/crf/crfHTML.js

+ 25 - 1
web/crf/crfHTML.js

@@ -27,7 +27,13 @@ crfHTML.addStyle=
 function(el,style){
    el.classList.add(style);
 }
- 
+
+
+crfHTML.clearStyle=
+function(el,style){
+   el.classList.remove(style);
+}
+
 crfHTML.createSelect=
 function(qMap,id=null,el=null){
    let fName='[makeSelect]';
@@ -180,4 +186,22 @@ function(input,qMap){
 	input.selectedIndex=0;	
 }
 
+crfHTML.updateSelect=
+function(input,cell,x,value){
+   let fName='[updateSelect]';
+   this.print(fName+' value '+value);
+   let children=cell.children;
+   for (let i=0;i<children.length;i++){
+      let el=children[i];
+      let lab=el.value;
+      this.print(fName+' style ['+el.className+']');
+      this.clearStyle(el,'teal');
+      if (lab==value){
+         lab+='[*]';
+         this.addStyle(el,'teal');
+      }
+      this.print(fName+' '+lab);
 
+   }
+   input.value=x;
+}