Edit numbers in the right column and the "total:" field will tell you their sum.
number #1 | 0 |
number #2 | 0 |
number #3 | 0 |
number #4 | 0 |
number #5 | 0 |
number #6 | 0 |
number #7 | 0 |
number #8 | 0 |
number #9 | 0 |
number #10 | 0 |
total: | 0 |
This sample demonstrates use of functions in CSSS!. Magick is done by the following rule:
value-changed!: total = 0, $(td.number) -> @(el) total = total + el:value, $1(td#total):value = total;
Declare variable total
with initial value 0.
Declare anonymous function @(el)
with single parameter el
and body of single statement:
total = total + el:value
$(td.number) '->' function
- call function on the right for each element of collection
on the left that is a set of elements satisfying $(td.number)
.
Set text of td#total
equal to the total
.