ARTICLE AD BOX
I have a HTML table, 13 rows versus 7 columns. The first 8 rows are used to enter numerical data like:
<td><input type="number" id="value1" class="tds"></td>and the next 5 rows are used to display five different calculations from those 8 rows:
<td><output type="number" id="c1"></td>Calculations are done on columns, 8 numerical values are used in column 1 to calculate average on row9 /column1, standard deviation on row 10/column 1, variation coefficient on row 11/column 1, and so on. The average value for all seven columns is calculated as follows:
function Medie(day) { getValues(); //as a1=Math.abs(parseInt(document.getElementById('value1').value)); var suma; var array; var medie=0; var count=7; switch(day) { case 1: suma=a1+a2+a3+a4+a5+a6+a7; array=day1; break; case 2: suma=b1+b2+b3+b4+b5+b6+b7; array=day2; break; case 3: suma=c1+c2+c3+c4+c5+c6+c7; array=day3; break; case 4: suma=d1+d2+d3+d4+d5+d6+d7; array=day4; break; case 5: suma=e1+e2+e3+e4+e5+e6+e7; array=day5; break; case 6: suma=f1+f2+f3+f4+f5+f6+f7; array=day6; break; case 7: suma=g1+g2+g3+g4+g5+g6+g7; array=day7; break; default: alert("Eroare Medie"); } if (array instanceof Array){ for(var i=0;i<array.length;i++) { if(array[i]!=0) { count++; suma+=array[i]; } } } medie=(suma/count).toFixed(1); return medie; }I would like to have the result of the calculation displayed in red if the value is above a certain preset numerical threshold and in green if it is below! Adding the code below to the function Medie(day) does not work:
if (medie > 154) { document.getElementById("value1").style.color = 'red'; } else { document.getElementById("value1").style.color = 'green'; }Any suggestions? Thank you!
