Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
4 replies
Subscribers
8 subscribers
Views
2208 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
#Forms I'm using the following JavaScript to calculate a number in my form:
sswilliams
over 10 years ago
#Forms I'm using the following JavaScript to calculate a number in my form:
window.FormAPI.setValue('number10', (window.FormAPI.getValue("number8").id * window.FormAPI.getValue("radio9").id));
The value needs to be displayed with 2 decimal places 0.89 instead of 0.89999999. The value is calculated dynamically on the form. Is there a way I can do this in Appian v6.6.1 using JavaScript?
I tried FormAPI.setFormatValue('text11',(window.FormAPI.getValue("text11").id),#.##); on the event rules (load) for the form, and I'm getting an exception error. Thanks......
OriginalPostID-85278
OriginalPostID-85278
Discussion posts and replies are publicly visible
Parents
0
Eduardo Fuentes
Appian Employee
over 10 years ago
Going back to your original code here's how you can do it using the JavaScript native Math.round() function:
var operandOne = window.FormAPI.getValue("number8").id;
var operandTwo = window.FormAPI.getValue("radio9").id;
window.FormAPI.setValue('number10',Math.round(operandOne * operandTwo * 100) / 100 );
Here's an example you can test with, just import this form in any model and test by typing something on number8, then selecting a value in cto see how number10 gets the result of rounding number8*radio9 to two decimals
forum.appian.com/.../108750
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Eduardo Fuentes
Appian Employee
over 10 years ago
Going back to your original code here's how you can do it using the JavaScript native Math.round() function:
var operandOne = window.FormAPI.getValue("number8").id;
var operandTwo = window.FormAPI.getValue("radio9").id;
window.FormAPI.setValue('number10',Math.round(operandOne * operandTwo * 100) / 100 );
Here's an example you can test with, just import this form in any model and test by typing something on number8, then selecting a value in cto see how number10 gets the result of rounding number8*radio9 to two decimals
forum.appian.com/.../108750
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data