Copy link to clipboard
Copied
Please fix this error.
var Exp = 'totalexperience';
var Sup = 'totalsup';
var f = this.getField(Exp).value;
var a = this.getField(Sup).value;
if(f==0)||(a==0)
{
event.value=f+a;
}
Else if(f!=0)||(a!=0)
{
event.value=a/f*100;
}
1 Correct answer
Change those two lines to:
if (f == 0 || a == 0)
else if (f != 0 || a != 0)
Note that it's else, not Else.
Copy link to clipboard
Copied
Change those two lines to:
if (f == 0 || a == 0)
else if (f != 0 || a != 0)
Note that it's else, not Else.
Copy link to clipboard
Copied
Thanks for reply.
Let me test it.
Copy link to clipboard
Copied
And by the way, it's JavaScript (one word, no space), not Java. Java is something entirely different.
(Moderation: topic's title edited)
This becomes very important if searching the web for advice, as Java is going to look enough like JavaScript to really mess you up.
Copy link to clipboard
Copied
Hi, i tried.. but not working..
see this error.
Copy link to clipboard
Copied
JavaScript is case sensitive. That is, you cannot write Else or ELSE when you mean else.
Copy link to clipboard
Copied
Yes, done..
please see this..
the calculation is going wrong.
why?
The answer would be like this:
(Total supervision hours / total experience hours ) * 100
so, (60/60)*100 = 100.
but why the answer went "100000" ?
thanks.
Copy link to clipboard
Copied
It's not 100000, it's 10000%. I suspect you set the field up with a percent format. To display 100%, you'd set the field value to 1. To display 31.5%, you'd set the field value to 0.315. When you set it to 100, it gets displayed as 100 * 100, or 10000%
Copy link to clipboard
Copied
100000 would be very hard to explain, but it's actually 10000 which is very easy to explain. I imagine you've defined this as a percentage field. If I remember correctly, a percentage field expects a value which is a fraction (such as 0.6) and displays it as a percentage (such as 60%). Either don't multiple by 100, or don't use a percentage field.
Copy link to clipboard
Copied
i am confusing, please write down here the code. thanks
Copy link to clipboard
Copied
just change the code do you do not muliply by 100.

