Math.floor does not work
I need help with this rounding:
var v3 = (this.getField("valor_for").value-10)/2;
event.value = Math.floor(v3);
I need the value of the operation always be rounded down
thanks
I need help with this rounding:
var v3 = (this.getField("valor_for").value-10)/2;
event.value = Math.floor(v3);
I need the value of the operation always be rounded down
thanks
A good way to debug these things (besides actually running in the JavaScript debugger and stepping through your code one line at a time) is to add debug output to your script. Add these two lines just after you calculate v3:
console.println("v3 = " + v3);
console.println("Math.floor(v3) = " + Math.floor(v3));
Now you can see what your script does. It works correctly for me.
If you are not getting the correct results, and if the value of the "valor_for" field is calculated as well, you need to check your calculation order (which is what I think Bernd wanted to say): If the 2nd field gets calculated before the results of the first field are available, then you are working with the previous value, which could explain the behavior you are seeing.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.