Copy link to clipboard
Copied
Hi,
I have a field wich the user enters the number of Kilometers they have made, and another field which takes that number times .53. If the number of KM is erased, the previous amount in the second field doesn't reset. How do I make sure that when a user erase the first field content, that the field with the calculation will also reset? Here's my script for the calculation, maybe that's where I'm doing it wrong.
var nKMs= this.getField("KMs").value
var nNumberKM = this.getField("NumberKM").value
if (nNumberKM > 0) event.value = nNumberKM * 0.53
TIA!
Copy link to clipboard
Copied
Remove this part from your code:
if (nNumberKM > 0)
Copy link to clipboard
Copied
HI Try67,
Thanks, but that part is actually what I wanted because I don't want anything displayed in the KMs field if there is nothing in the NumberKM field. That's the only way I found, but maybe there is a better way of doing this.
I want the amount to be displayed for some field only if there are an entry in the NumberKM. If the person doesn't have anything to put in that field, I don't want to see 0.00$ in the KMs field.
I took the same approche for the tax fields, if the person doesn't have a tax number, than no amount is displayed. Again, that was the only way I found that worked. If you guys have a better way, I'm all for it. But if the field is set to empty afterward, then the problem I have is that the old amount stays in the KMs field, not good.
Thanks again!
Copy link to clipboard
Copied
Then add this to the end of the original code:
else event.value = "";
Copy link to clipboard
Copied
Thanks Try67, this is exacly what I wanted!