modbcheckbox for non-boolean (integer) types stays always checked

Issue #374 resolved
Lukas Berns created an issue

The ODB entry gets changed to 0, but the checkbox stays checked regardless of 0 or 1. This is because mvalue returned by mie_to_string is "0" or "1" so that due to the javascript type difference we always have mvalue !== 0.

I think this was introduced in ba04e7ebe. An easy fix would be

diff --git a/resources/mhttpd.js b/resources/mhttpd.js
index 0978833..c9bb8ac 100644
--- a/resources/mhttpd.js
+++ b/resources/mhttpd.js
@@ -2465,7 +2465,7 @@ function mhttpd_refresh() {
          if (typeof x === "boolean")
             modbcheckbox[i].checked = x;
          else
-            modbcheckbox[i].checked = (mvalue !== 0);
+            modbcheckbox[i].checked = (mvalue !== '0');
          if (modbcheckbox[i].onchange !== null)
             modbcheckbox[i].onchange();
          if (modbcheckbox[i].dataset.odbLoaded === undefined && modbcheckbox[i].onload !== null) {

Comments (1)

  1. Log in to comment