Thank you very much for your help. As you must have guessed I know almost nothing of coding. As I’m 57 years old, that’s perhaps understandable. What I’m trying to do is to get the number of books (qtd) I have sold from a particular author (autor) in a chosen month. I have the collection and a repeater. The entire code I’ve tried is as follows. It works fine, except the results which are shown just for each repeater page, and not the sum altogether. Is this information enough for your kind help?
Thanks a lot
$w . onReady ( function () {
$w ( “#btnSomar” ). onClick (()=>{
calcular ()
})
let itens = [
{ “_id” : “0001” , “item” : “mes” , “qtd” : 0 },
]
$w ( “#repAutor” ). data = itens
$w ( “#repAutor” ). forEachItem (( $item , itemData )=>{
$item ( “#txtItem” ). text = itemData . item
$item ( “#tbQuantidade” ). value = itemData . qtd
})
});
function calcular (){
let itemNaLista = $w ( “#repAutor” ). data
$w ( “#repAutor” ). forEachItem (( $item , itemData , index )=>{
itemNaLista [ index ]. qtd = $item ( “#tbQuantidade” ). value
})
let total = itemNaLista . reduce (( total , item ) => total + Number ( item . qtd ), 0 );
$w ( "#txtSoma" ). text = String ( total )
$w ( "#txtSoma" ). show ()
}