# Issue setting date picker value

**URL:** <https://forum.wixstudio.com/t/issue-setting-date-picker-value/36034>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [September 6, 2022, 8:49pm UTC](https://forum.wixstudio.com/t/issue-setting-date-picker-value/36034 "2022-09-06T20:49:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![StevenW](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/stevenw/32/86678_2.png) [@StevenW](https://forum.wixstudio.com/u/StevenW)\
**Post date:** [September 6, 2022, 8:49pm UTC](https://forum.wixstudio.com/t/issue-setting-date-picker-value/36034/1 "2022-09-06T20:49:17Z")

</div>

I’m trying to populate a value for a date picker in a page’s $w . onReady function. The code is very simple.

```javascript
$w('#datePicker1').value = new Date("2022-09-15");

```

This works if the date picker’s default value is set to “Today”. If I change the default to “Nothing” or “Placeholder text”, the value I set in code seems to get overwritten during loading and the value ends up being “null”. If I wait 1 second before setting the value, it works as expected.

```javascript
setTimeout(()=> { $w('#datePicker1').value = new Date("2022-09-15"); }, 1000);

```

The date picker doesn’t have its own onReady function to see if it’s done setting the default value.

Conversely, if I want to set the date picker to be blank, but the default is set to “Today”, it puts today’s date in there after I cleared it in the $w.onReady function.

It seems like the problem is that the date picker is getting it’s default value set after or during the onReady, not before. And it takes almost half a second to complete.

---

<div class="post-metadata">

**Author:** ![aslam-percy-husain](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/aslam-percy-husain/32/35790_2.png) [@aslam-percy-husain](https://forum.wixstudio.com/u/aslam-percy-husain)\
**Post date:** [April 3, 2023, 6:13pm UTC](https://forum.wixstudio.com/t/issue-setting-date-picker-value/36034/2 "2023-04-03T18:13:09Z")

</div>

Thank you for posting this. I had a nightmare trying to figure out why I couldn’t set the date picker’s value manually. Setting a timeout in $w.onReady works but it’s obviously not an ideal solution.
