Round Function

neetu
Community Member Posts: 5
In your title, set up a new HTML object, and set Object Type to Header Scripting.Enter the following code:
Then set up a new action:On: ShowAction: Modify VariableTarget: RoundedNumberValue: javascript:PercentRound(VarOriginalNumber)Modification Type: Set Variable ContentsThis assumes that you have a number set up as a variable called OriginalNumber. You'll need to repeat this action with new variables for however many rounded numbers you have on the page. Name the variables OriginalNumber1, RoundedNumber1, OriginalNumber2, RoundedNumber2, etc.
Code:
function PercentRound(obj) {var a = obj.getValue();a = Math.round(a);return a;}
Then set up a new action:On: ShowAction: Modify VariableTarget: RoundedNumberValue: javascript:PercentRound(VarOriginalNumber)Modification Type: Set Variable ContentsThis assumes that you have a number set up as a variable called OriginalNumber. You'll need to repeat this action with new variables for however many rounded numbers you have on the page. Name the variables OriginalNumber1, RoundedNumber1, OriginalNumber2, RoundedNumber2, etc.
Categories
- 35.8K All Categories
- 109 ✫ Announcements
- 33.1K Lectora®
- 31.1K Lectora Discussions
- 28.9K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 36 Lectora Accessibility User Group (LAUG)
- 22 ELB Learning Content
- 22 ELB Learning Content Discussions
- 321 CenarioVR®
- 188 CenarioVR Discussions
- 133 CenarioVR Feature Requests
- 41 Rockstar Learning Platform®
- 38 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 47 ReviewLink®
- 47 ReviewLink Discussions
- 7 The Training Arcade®
- 7 The Training Arcade Discussions
- 934 All Things eLearning
- 36 eLearning Development
- 546 Learning Management System (LMS) Integration
- 332 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products