# Can't update item in repeater dataset

**URL:** <https://forum.wixstudio.com/t/cant-update-item-in-repeater-dataset/5725>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [October 25, 2021, 11:08pm UTC](https://forum.wixstudio.com/t/cant-update-item-in-repeater-dataset/5725 "2021-10-25T23:08:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmglick1](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/nmglick1/32/30573_2.png) [@nmglick1](https://forum.wixstudio.com/u/nmglick1)\
**Post date:** [October 25, 2021, 11:08pm UTC](https://forum.wixstudio.com/t/cant-update-item-in-repeater-dataset/5725/1 "2021-10-25T23:08:44Z")

</div>

I created a fairly straightforward project consisting of a submission form (write-only **2022customerInfo** dataset) for purchasing plants and a repeater connected to a dataset (read/write **2022PlantSale** ) containing name, image, description, cost and inventory.  
Everything works well, except I’ve not been able to update the 2022PlantSale dataset ‘plantInventory’ items of plants that have been purchased. The submit button is not linked to either dataset, but executes save()'s in the event handler. Whatever I try, usually only the first row item gets modified. Any help would be greatly appreciated.

```javascript
import wixData from 'wix-data';
//import setTimeDate from 'backend/setTimeDate';
import {sendEmail, sendEmailWithRecipient} from 'backend/email';

var saveInventory = [];//Original count array
var newInventory = []; //Updated count array
var saveTotal = 0; //Global total cost of plant selections
var saveTotalText = "";

const pcArray = [
    "pc1","pc2","pc3","pc4","pc5","pc6","pc7","pc8","pc9","pc10",
    "pc11","pc12","pc13","pc14","pc15","pc16","pc17","pc18","pc19","pc20"
];
const pcCountArray = ["pc1Count","pc2Count","pc3Count","pc4Count","pc5Count","pc6Count",
"pc7Count","pc8Count","pc9Count","pc10Count","pc11Count","pc12Count","pc13Count","pc14Count",
"pc15Count","pc16Count","pc17Count","pc18Count","pc19Count","pc20Count"
];

```

```javascript
$w.onReady(function() {
    $w("#2022PlantSale").onReady(() => {
        $w("#2022customerInfo").onReady (() => {
            $w("#countNote").text = ""; //Count too-high error
            $w("#totalCost").text = "0"; //Total cost text box
            $w("#paypalButton1").hide();
            $w('#submit').disable()
            .then((item) => {
              makeRepeater();
            })
            .catch((err) => {
              console.log("Submit button disable error", err);
            });
        });
    });
  });
  
function makeRepeater() {
    //$w("#addToCart").hide(); //disable all Add to Cart buttons
    $w("#inpCount").value = ""; //and blank global count values
    $w("#plantRepeater").forEachItem(($item, itemData, index) => {
       saveInventory[index] = newInventory[index] = $item('#plantCount').text;
       if (saveInventory[index] == "0") {
          $item("#addToCart").hide(); //Enable button if inventory non-zero
          $item("#inpCount").disable();
        }
        console.log ("itemData = ",itemData);
    });
}

export async function submit_click(event) {
if (!($w("#inpFirstName").valid && //Make sure must-have data entered
    $w("#inpLastName").valid &&
    $w("#inpPhone").valid)) {
      $w("#fieldError").show();
      return;
    }
    $w("#fieldOk").hide(); //Hide success message
    $w('#2022customerInfo').setFieldValues(setTimeDate($w("#totalCost").text));
    //Go through repeater containers to update inventories
    // ****************Just using the index as a test***************
    $w("#plantRepeater").forEachItem(($item, itemData, index) => {
      itemData.plantInventory = index.toString();
      /*$w("#2022PlantSale").setCurrentItemIndex(index) //This stuff didn't work
      .then((result) => {                                
          console.log("result = ",result);
        })
        .catch((error) => {
          console.log("Error = ", error);
        });
      */
      $item("#plantCount").text = (index).toString(); //Inventory text box
      console.log ("index, itemData = ", index," ", itemData);
    });
      
    await $w("#2022PlantSale").save();
    await $w("#2022customerInfo").save();
    $w("#fieldOk").show();
    $w("#paypalButton1").show('fade');
    await $w("#paypalButton1").postMessage("99");
    console.log("total cost = ", saveTotal.toString());
    console.log ("old = ", saveInventory, "New = ", newInventory);
    saveTotal = 0;
}

```
