Page 1 of 2

How do you set the default date within the date picker to today's date?

Posted: Mon May 13, 2013 1:36 am
by Nathan Kahl

The article that explains how to do this is no longer available...


How do you set the default date within the date picker to today's date?

Posted: Mon May 13, 2013 3:40 am
by Igor

Add javascript code on screen load:

precode
var currDate = new Date();
$('div[dsid="mobiledatepicker1"] input').val((currDate.getMonth()+1)+'/'+currDate.getDate()+'/'+currDate.getFullYear());
/code/pre
Make sure the component is called 'mobiledatepicker1' or use whatever name you set.


How do you set the default date within the date picker to today's date?

Posted: Mon Sep 15, 2014 10:03 pm
by Mike6979865

I used this code, and it shows the date. However, when I click on search nothing appears. I would have to then manually click on calender, and select the same date. So, I have on click set local storage variable which is the date. However, even though the correct date is in the box, it's not recognizing it when it's showing today's date.


How do you set the default date within the date picker to today's date?

Posted: Tue Sep 16, 2014 2:28 am
by Alena Prykhodko

Hello Mike,

Please show us screen shot.
Please note, by default datepicker component displays current today date http://devcenter.appery.io/documentat...


How do you set the default date within the date picker to today's date?

Posted: Tue Sep 16, 2014 3:42 pm
by Mike6979865

The thing is it's asking me to set a default day. I can't delete that. I want today's date to show when I run the program.

Image


How do you set the default date within the date picker to today's date?

Posted: Tue Sep 16, 2014 10:52 pm
by Yurii Orishchuk

Hi Mike,

Following code works for me:

pre

//Create date. You can set here the date you need.
var currDate = new Date();

//Note: you should replace "mobiledatepicker_132" with your datepicker component.
$('div[dsid="mobiledatepicker_132"] input').val((currDate.getMonth()+1)+'/'+currDate.getDate()+'/'+currDate.getFullYear());

console.log("Set date for datepicker component as = '" + (currDate.getMonth()+1)+'/'+currDate.getDate()+'/'+currDate.getFullYear() + "'");

/pre

So you can run this code on "page show" event and do not care about default date in component properties.

Regards.


How do you set the default date within the date picker to today's date?

Posted: Wed Sep 17, 2014 3:06 pm
by Mike6979865

Worked like magic ! :) Thank you Yurii.


How do you set the default date within the date picker to today's date?

Posted: Wed Sep 17, 2014 6:02 pm
by Mike6979865

Well, yes, it did show today's date, but I still have the same problem. When I click on Search, it's now reading the value that is showing in the textbox of the date picker. Here's a screen shot

Image


How do you set the default date within the date picker to today's date?

Posted: Wed Sep 17, 2014 6:03 pm
by Mike6979865

Well, yes, it did show today's date, but I still have the same problem. When I click on Search, it's now reading the value that is showing in the textbox of the date picker. Here's a screen shot

Image


How do you set the default date within the date picker to today's date?

Posted: Thu Sep 18, 2014 12:00 am
by Yurii Orishchuk

Hi Mike,

Can not understand your problem.

Please give us more details.

Regards.