Skip to main content
Known Participant
March 12, 2024
Answered

Getting field value 0 if the calue is grater than 0

  • March 12, 2024
  • 1 reply
  • 1832 views

var J = Number(this.getField("V10").valueAsString);
var K = eval(this.getField("F10").valueAsString);
var d = Number(this.getField("H1").valueAsString);
var e = this.getField("D10").valueAsString;
var f = Number(this.getField("I1").valueAsString);

event.value = "";

if (e !== "") {
e = Number(e);
if (e === 0) {
event.value = "<LOD";
} else {
var total;
if (J !== 0 && f !== 0) {
total = (K * d) / (J * f);
event.value = total.toFixed(3);
}
}
}

Hi, 

in above script when I write 0/100 in K, the value appearing correct in E. But when I write 1/100 is F. Attached pdf link for file. 

Lab. 2.29.24_2 updated.pdf

This topic has been closed for replies.
Correct answer Nesa Nurani

I need the cell shows value. Is there any option we can achieve that?


Use another condition:

if (J == 0 && f == 0) {
total = (K * d);  ?

1 reply

try67
Community Expert
Community Expert
March 12, 2024

J7 is zero so the result of this formula is invalid (since division by zero is not allowed):

total = (K * d) / (J * f);

BhuweshAuthor
Known Participant
March 12, 2024

can you tell me correct script to get the result. 

 

BhuweshAuthor
Known Participant
March 14, 2024

Use another condition:

if (J == 0 && f == 0) {
total = (K * d);  ?


I used this 

var J = Number(this.getField("V1").valueAsString);
var K = eval(this.getField("F1").valueAsString);
var d = Number(this.getField("H1").valueAsString);
var e = this.getField("D1").valueAsString;
var f = Number(this.getField("I1").valueAsString);

event.value = "";

if (e !== "") {
e = Number(e);
var total;
if (J !== 0 && f !== 0) {
total = (K * d) / (J * f);
} else if (J === 0 && f === 0) {
total = K * d;
} else if (J === 0) {
total = (K * d) / f;
} else {
total = (K * d) / J; // If f is 0,
}
event.value = total.toFixed(3);
}