'Javascript to fill definite values only
I am trying to use a JS code to fill up elements with their already filled up values as desribed in the table here

The JS code suggested by some members here which has worked partially is this:
document.querySelectorAll("[id^='1253']")
.forEach(o => {
if (o.value) o.value = `(${o.value})`;
});
Problem is that I need this condition that, if value =>0.9 then also it should NOT do the prepend and append function and leave the value as it is like shown in the table picture above. The code above is filling for all non-blank values (including values=>0.9). Please help me to solve my problem. Regards, Vicky.
Solution 1:[1]
document.querySelectorAll("[id^='1253']")
.forEach(o => {
if (o.value && parseFloat(o.value) < 0.9)
o.value = `(${o.value})`;
});
just do add another condition parseFloat(o.value) < 0.9 means only the value with below 0.9 will be changed. parseFloat parses the o.value to float so it can be compared to 0.9
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
