浏览代码

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 年之前
父节点
当前提交
77d15c6f6c
共有 1 个文件被更改,包括 25 次插入1 次删除
  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;
+}