2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

fhemweb.js: selectnumbers: accept number without .0 (Forum #107761)

git-svn-id: https://svn.fhem.de/fhem/trunk@21057 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-01-26 14:04:57 +00:00
parent f497147493
commit 310a170c32

View File

@ -1513,7 +1513,7 @@ FW_createSelectNumbers(elName, devName, vArr, currVal, set, params, cmd)
for(var j=min; j <= max; j+=stp) { for(var j=min; j <= max; j+=stp) {
var o = document.createElement('option'); var o = document.createElement('option');
o.text = o.value = j.toFixed(dp); o.text = o.value = j.toFixed(dp);
vHash[j.toString()] = 1; vHash[o.text] = 1;
newEl.options[k] = o; newEl.options[k] = o;
k++; k++;
} }
@ -1540,7 +1540,11 @@ FW_createSelectNumbers(elName, devName, vArr, currVal, set, params, cmd)
$(newEl).attr('name', elName); $(newEl).attr('name', elName);
if(cmd) if(cmd)
$(newEl).change(function(arg) { cmd($(newEl).val()) }); $(newEl).change(function(arg) { cmd($(newEl).val()) });
newEl.setValueFn = function(arg) { if(vHash[arg]) $(newEl).val(arg); }; newEl.setValueFn = function(arg) {
arg = parseFloat(arg).toFixed(dp);
if(vHash[arg])
$(newEl).val(arg);
};
return newEl; return newEl;
} }