# Wix-data insert( ) with inputs elements

**URL:** <https://forum.wixstudio.com/t/wix-data-insert-with-inputs-elements/1295>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [May 5, 2021, 3:39pm UTC](https://forum.wixstudio.com/t/wix-data-insert-with-inputs-elements/1295 "2021-05-05T15:39:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danmatley](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/danmatley/32/27961_2.png) [@danmatley](https://forum.wixstudio.com/u/danmatley)\
**Post date:** [May 5, 2021, 3:39pm UTC](https://forum.wixstudio.com/t/wix-data-insert-with-inputs-elements/1295/1 "2021-05-05T15:39:27Z")

</div>

I’ve got a simple bit of code I can’t get working. It creates an entry into my Collection but the field values are empty - and the text input fields are filled in before submitButton is pressed.

```javascript
import wixData from 'wix-data';

let toInsert = {
 "title": $w("#title").value,
 "region": $w("#region").value,
 "price": $w("#price").value,
};

$w.onReady(function () {
    
});

export function submitButton_click(event) {
 wixData.insert("Collection", toInsert);
}

```

---

<div class="post-metadata">

**Author:** ![tony-brunsman](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tony-brunsman](https://forum.wixstudio.com/u/tony-brunsman)\
**Post date:** [May 5, 2021, 4:07pm UTC](https://forum.wixstudio.com/t/wix-data-insert-with-inputs-elements/1295/2 "2021-05-05T16:07:38Z")

</div>

Currently, the toInsert object is being assigned as the page loads when those elements have no value or have not been loaded yet. The object will have the values of the elements at the time the button is clicked if the code is placed at the top of the submitButton\_click function.

---

<div class="post-metadata">

**Author:** ![danmatley](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/danmatley/32/27961_2.png) [@danmatley](https://forum.wixstudio.com/u/danmatley)\
**Post date:** [May 5, 2021, 5:04pm UTC](https://forum.wixstudio.com/t/wix-data-insert-with-inputs-elements/1295/3 "2021-05-05T17:04:54Z")

</div>

Perfect, thank you Anthony
