# How to create var for input field in array (not using data grid)?

**URL:** <https://community.weweb.io/t/how-to-create-var-for-input-field-in-array-not-using-data-grid/807>\
**Category:** How do I?\
**Tags:** binding\
**Created:** [July 16, 2022, 5:55am UTC](https://community.weweb.io/t/how-to-create-var-for-input-field-in-array-not-using-data-grid/807 "2022-07-16T05:55:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anna.fae](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/anna.fae/32/776_2.png) [@Anna.fae](https://community.weweb.io/u/Anna.fae)\
**Post date:** [July 16, 2022, 5:55am UTC](https://community.weweb.io/t/how-to-create-var-for-input-field-in-array-not-using-data-grid/807/1 "2022-07-16T05:55:08Z")

</div>

I display a shopping cart array with object for each product added to shopping cart

I want user to update amount of products in shopping cart

Ive added input field to my list of products and I bind initial value of input to existing amount of items for specific product

when user change number in that input I want to change object.amount

When input is in the array it has no variables that I can bind to my formula

Is there any way to create vars or should I only use DataGrid feature for that?  
It looks like easier to update only 1 field with just generating a vars for each input in array like my example then customise DataGrid…

 ![Screenshot 2022-07-16 at 07.34.37](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/1X/a6413f5216c23a93f72b1dcaee72ed1463c68799.png)

---

<div class="post-metadata">

**Author:** ![kevinwasie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kevinwasie/32/402_2.png) [@kevinwasie](https://community.weweb.io/u/kevinwasie)\
**Post date:** [July 16, 2022, 1:11pm UTC](https://community.weweb.io/t/how-to-create-var-for-input-field-in-array-not-using-data-grid/807/2 "2022-07-16T13:11:17Z")

</div>

Use an onChange workflow. When the user changes the quantity, update the array variable.

Again. You’ll need a tiny bit of JavaScript:

1. For that quantity input, add an onChange workflow
2. add a custom JavaScript action

The custom code should be something like this for your variable names:

variables.ShoppingCart[context.item.index].quantity = event.value;
