# adding user input values inside a repeater

**URL:** <https://forum.wixstudio.com/t/adding-user-input-values-inside-a-repeater/20713>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [September 7, 2019, 3:11am UTC](https://forum.wixstudio.com/t/adding-user-input-values-inside-a-repeater/20713 "2019-09-07T03:11:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian39460](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/brian39460/32/10317_2.png) [@brian39460](https://forum.wixstudio.com/u/brian39460)\
**Post date:** [September 7, 2019, 3:11am UTC](https://forum.wixstudio.com/t/adding-user-input-values-inside-a-repeater/20713/1 "2019-09-07T03:11:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brian39460](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/brian39460/32/10317_2.png) [@brian39460](https://forum.wixstudio.com/u/brian39460)\
**Post date:** [September 7, 2019, 3:18am UTC](https://forum.wixstudio.com/t/adding-user-input-values-inside-a-repeater/20713/2 "2019-09-07T03:18:02Z")

</div>

Sorry!!

```javascript
$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()

}

```

---

<div class="post-metadata">

**Author:** ![brian39460](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/brian39460/32/10317_2.png) [@brian39460](https://forum.wixstudio.com/u/brian39460)\
**Post date:** [September 7, 2019, 3:54pm UTC](https://forum.wixstudio.com/t/adding-user-input-values-inside-a-repeater/20713/3 "2019-09-07T15:54:57Z")

</div>

www.prattys.bar/update-cribbage-game

The page has a password: WixHelp

---

<div class="post-metadata">

**Author:** ![givemeawhisky](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/givemeawhisky/32/5383_2.png) [@givemeawhisky](https://forum.wixstudio.com/u/givemeawhisky)\
**Post date:** [September 7, 2019, 8:45pm UTC](https://forum.wixstudio.com/t/adding-user-input-values-inside-a-repeater/20713/4 "2019-09-07T20:45:04Z")

</div>

Did you see Yisrael’s example post about inputs in repeaters?  
[https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-input-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.
