adding user input values inside a repeater

I have a repeater that is linked to a dataset. There are 8 user input boxes set as type “number”. This is for a 4 game head to head match up where I would like to have it automatically add up the scores input and place them in a totals box (and subsequently update the dataset record with all of the new information when I click a button in the repeater item. I’m currently stuck trying to understand how to properly work with the “current item” in the repeater. Here is what I have for code right now.

$w.onReady( function () {
//TODO: write your page related code here…

});

export function calcTotals () {
$w(“#repeater1”).forEachItem( ($item, itemData, index) => {
//if ()
console.log(“ifstarted”)
var p1Tot= parseInt($item(“#p1Score1”).itemData, 10) + parseInt($item(“#p1Score2”).itemData, 10) + parseInt($item(“#p1Score3”).itemData, 10) + parseInt($item(“#p1Score4”).itemData, 10);
$item(“#p2Total”).value = parseInt($item(“#p2Score1”).value, 10) + parseInt($item(“#p2Score2”).value, 10) + parseInt($item(“#p2Score3”).value, 10) + parseInt($item(“#p2Score4”).value, 10);
console.log(p1Tot)
console.log(“between”)
}
)

}

export function button1_click(event) {
//Add your code for this event here:
console.log(“pressed button”)
calcTotals()

}

I appreciate any help I can get on this, I am a beginner when it comes to writing code.

Sorry!!

$w.onReady(function () {
 //TODO: write your page related code here...

});

export function calcTotals () {
    $w("#repeater1").forEachItem( ($item, itemData, index) => {
//if () 
console.log("ifstarted")
//if (itemData.p1Score1 > 0) {
 var p1Tot= parseInt($item("#p1Score1").itemData, 10) + parseInt($item("#p1Score2").itemData, 10) + parseInt($item("#p1Score3").itemData, 10) + parseInt($item("#p1Score4").itemData, 10);
    $item("#p2Total").value = parseInt($item("#p2Score1").value, 10) + parseInt($item("#p2Score2").value, 10) + parseInt($item("#p2Score3").value, 10) + parseInt($item("#p2Score4").value, 10);
//} $item("#p1Total").value 
console.log(p1Tot)
console.log("between")
}
    )
 
}

export function button1_click(event) {
 //Add your code for this event here: 
    console.log("pressed button")
    calcTotals()

}

www.prattys.bar/update-cribbage-game

The page has a password: WixHelp

Did you see Yisrael’s example post about inputs in repeaters?
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-input-repeaters

You can open up his example in your own editor and see the page and the code all setup for you.