# Transfer Datepicker value to new page

**URL:** <https://forum.wixstudio.com/t/transfer-datepicker-value-to-new-page/8151>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [December 23, 2022, 10:36am UTC](https://forum.wixstudio.com/t/transfer-datepicker-value-to-new-page/8151 "2022-12-23T10:36:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![menon-alessandro](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/menon-alessandro/32/2860_2.png) [@menon-alessandro](https://forum.wixstudio.com/u/menon-alessandro)\
**Post date:** [December 23, 2022, 10:36am UTC](https://forum.wixstudio.com/t/transfer-datepicker-value-to-new-page/8151/1 "2022-12-23T10:36:18Z")

</div>

Dear all,  
I would need help with transferring a value collected from a date picker on page 1 to another date picker on page 2. I have found a similar post but it does not seem to work for me.

The code I currently have is:

**On page 1** :  
import { session } **from** ‘wix-storage’ ; // activates wix-storage  
import wixlocation **from** ‘wix-location’ ;  
$w . onReady ( **function** () {

```
//DROPDOWN FILTER 
$w ( '#searchbutton' ). onClick (() => { 
session . setItem ( "citychoice" , $w ( "#citypick" ). value );  
**let** startdate = String ( $w ( '#datePicker1' ). value ); 
session . setItem ( "datechoice" , startdate ) 
wixlocation . to ( "/rooms" ); 
}); 

```

});

**On page 2** :  
import wixData **from** ‘wix-data’ ;  
import { session } **from** ‘wix-storage’ ;  
import wixLocation **from** ‘wix-location’ ;

//IMPORT VALUES AND FILTER  
$w . onReady ( **function** () {  
$w ( ‘#citypick2’ ). value = session . getItem ( “citychoice” )  
**var** startdate = **new** Date ( session . getItem ( “datechoice” ));  
$w ( ‘#datePicker1’ ). value = startdate ;  
wixData . query ( “Rooms” )  
. lt ( “availability” , $w ( “#datePicker1” ). value )  
. and ( wixData . query ( “Rooms” ). contains ( “city” , String ( $w ( ‘#citypick2’ ). value )))  
. find ()  
. then ( results =\> {  
$w ( ‘#RoomRepeater’ ). data = results . items ;  
session . clear ();  
})

The above code works for the first condition (i.e. city choice, but not for the date picker, whose value is not passed to page 2)

Any help on this would be highly appreciated.  
Alessandro

---

<div class="post-metadata">

**Author:** ![bilonii](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bilonii/32/15984_2.png) [@bilonii](https://forum.wixstudio.com/u/bilonii)\
**Post date:** [December 23, 2022, 10:58am UTC](https://forum.wixstudio.com/t/transfer-datepicker-value-to-new-page/8151/2 "2022-12-23T10:58:56Z")

</div>

Hi!

**Page 1:**

```javascript
import {session} from 'wix-storage'; // activates wix-storage
import wixlocation from 'wix-location';

$w.onReady(function () {
    //DROPDOWN FILTER
    $w('#searchbutton').onClick(() => {
        session.setItem("citychoice", $w("#citypick").value); 
        let startdate = String($w('#datePicker1').value);
        console.log(startdate); // log the date picker value to the console
        session.setItem("datechoice", startdate);
        wixlocation.to("/rooms");
    });
});

```

Page 2:

```javascript
import wixData from 'wix-data';
import { session } from 'wix-storage';
import wixLocation from 'wix-location';

$w.onReady(function () {
    $w('#citypick2').value = session.getItem("citychoice");
    var startdate = new Date(session.getItem("datechoice")); // create a JavaScript Date object
    console.log(startdate); // log the date value to the console
    $w('#datePicker1').value = startdate;
    wixData.query("Rooms")
    .lt("availability", startdate) // use the startdate variable in the filter query
    .and(wixData.query("Rooms").contains("city", String($w('#citypick2').value)))
    .find()
    .then(results => {
        $w('#RoomRepeater').data = results.items;
        session.clear();
    });
});

```

If you get Errors, write it that i can better understand what the problem is 🙂

---

<div class="post-metadata">

**Author:** ![menon-alessandro](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/menon-alessandro/32/2860_2.png) [@menon-alessandro](https://forum.wixstudio.com/u/menon-alessandro)\
**Post date:** [December 23, 2022, 12:35pm UTC](https://forum.wixstudio.com/t/transfer-datepicker-value-to-new-page/8151/3 "2022-12-23T12:35:34Z")

</div>

Thank you very much, it works now!
