소스 검색

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;
+}