Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 10: | Line 10: | ||
i + 1 // but instead, this is the final statement, so the result will be 3 | i + 1 // but instead, this is the final statement, so the result will be 3 | ||
</source> | </source> | ||
{{FieldNameHint}} | |||
== Script == | |||
; Script itself | |||
: JavaScript script. The context of the script is the [[Triggers#Object Entry|'''Entry object''']]. The value returned is the last value assigned or expressed. | |||
; JavaScript Libraries | |||
: Choose additional JavaScript Libraries to be loaded. At this time, only moment.min.js is available. | |||
; Execute script in real time: | |||
:; No (default) | |||
:: Script will run only upon edit. Performance will be enhanced. | |||
:; Yes | |||
:: Script will run upon edit or display. | |||
== Display Options == | |||
{{FieldRoleRNDS}} | |||
{{FieldOnCard}} | |||
{{FieldFont}} | |||
{{FieldDepend}} | |||
== Fields of an entry == | == Fields of an entry == | ||
Line 172: | Line 198: | ||
To calculate the cost of the order, the JavaScript field '''Cost''' can be computed as follows: | To calculate the cost of the order, the JavaScript field '''Cost''' can be computed as follows: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var items = field('Items'); // CHANGE Items to your link field name | |||
var cost = 0; | var cost = 0; | ||
for (var i in items) | for (var i in items) | ||
cost += items[i].field('Quantity') * items[i].field('Price'); | cost += items[i].field('Quantity') * items[i].field('Price'); | ||
cost; // The result is the COMPUTED COST | |||
</source> | </source> | ||
Line 181: | Line 209: | ||
You can find a full description of the language [https://developer.mozilla.org/docs/Web/JavaScript '''here''']. | You can find a full description of the language [https://developer.mozilla.org/docs/Web/JavaScript '''here''']. | ||
The implementation is based on the [https://www.mozilla.org/rhino/ '''Rhino library''']. | The implementation is based on the [https://www.mozilla.org/rhino/ '''Rhino library''']. | ||
== JavaScript links == | == JavaScript links == |