Page 1 of 1

Date Picker options

PostPosted: Sat Aug 19, 2017 6:24 pm
by TMcD
I'll start off by stating that I think NeoBook should have a datepicker built in.

Now my next question is how to go about it on my own... (I don't want to use a 3rd party plugin, since unfortunately I don't want to rely on a 3rd party since most disappear and my app needs to remain solid.)

I'd like to use drop downs, Select Month, Day and Year. The only problem is figuring out leap year, meaning...

I don't want to just allow day selection of 1-31 because not all months have 31 days and for February, I'd need to figure if it was a leap year or not.

My app allows people to set one future specific date.

Any ideas while I go through the forum? :)

Thanks.

Re: Date Picker options

PostPosted: Sat Aug 19, 2017 6:42 pm
by Gaev
TMcD:

I'd like to use drop downs, Select Month, Day and Year.

Suggest you make them part of a Custom Window ... so you can invoke with just one command.

The only problem is figuring out leap year, meaning...
I don't want to just allow day selection of 1-31 because not all months have 31 days and for February, I'd need to figure if it was a leap year or not.
Any ideas while I go through the forum? :)

Check if a particular year is a LEAP year - http://www.scriptedlogic.com/zzold/neoHOW6.htm

Suggest you make the logic a Called Function ... so you can reuse from anywhere in any number of pubs.

Re: Date Picker options

PostPosted: Sat Aug 19, 2017 6:47 pm
by TMcD
Ok, so I didn't find anything (quickly in the forum), so I thought I could find a Javascript, and I did.

I created a JScript Function:

Code: Select all
// Get Year from NeoBook [Year]

var tempYear = nbGetVar( '[Year]' );

// Found this formula online
// Not a Leap Year Returns: False
// A Leap Year Returns: True

LeapYearVerify = (tempYear % 100 === 0) ? (tempYear % 400 === 0) : (tempYear % 4 === 0);

// Set NeoBook Variable

nbSetVar("[IsItLeapYear]", LeapYearVerify);


This takes the current year checks if it is a Leap Year and returns a True if it is, or False if it is not a leap year. The result is stored in variable [IsItLeapYear]

And Bob's your uncle. :)

* I tried to make it easy to understand so that others can try some Javascript as well. I'm not an expert, just slightly dangerous. :)

Re: Date Picker options

PostPosted: Sat Aug 19, 2017 7:11 pm
by TMcD
Gaev wrote:TMcD:

I'd like to use drop downs, Select Month, Day and Year.

Suggest you make them part of a Custom Window ... so you can invoke with just one command.

The only problem is figuring out leap year, meaning...
I don't want to just allow day selection of 1-31 because not all months have 31 days and for February, I'd need to figure if it was a leap year or not.
Any ideas while I go through the forum? :)

Check if a particular year is a LEAP year - http://www.scriptedlogic.com/zzold/neoHOW6.htm

Suggest you make the logic a Called Function ... so you can reuse from anywhere in any number of pubs.

Thanks. I will make note of this too. I'm always learning with NeoBook. I also appreciate forum helpers such as yourself.
* The way you pointed to won't rely on Javascript, which is good, though relying on Javascript shouldn't be an issue (I think) :shock:

Re: Date Picker options

PostPosted: Sat Aug 19, 2017 7:49 pm
by Neosoft Support
DBPro has a date picker action (dbpPopupDateSelector). It can be used for non-database applications.

Re: Date Picker options

PostPosted: Mon Aug 21, 2017 11:37 am
by TMcD
Neosoft Support wrote:DBPro has a date picker action (dbpPopupDateSelector). It can be used for non-database applications.


And NeoBook itself should have one as well. :D

Re: Date Picker options

PostPosted: Mon Aug 21, 2017 1:57 pm
by dpayer
TMcD wrote:I'll start off by stating that I think NeoBook should have a datepicker built in.

Now my next question is how to go about it on my own... (I don't want to use a 3rd party plugin, since unfortunately, I don't want to rely on a 3rd party since most disappear and my app needs to remain solid.)

Thanks.


I created a function and a template you can use as a date picker. I use it in a couple of my apps.

I have a standalone demo but you can embed just the calendar on your page. See this page:

viewtopic.php?f=22&t=20140
Image

Let me know if you need help implementing. It is all NB script an and NB objects.

Re: Date Picker options

PostPosted: Mon Aug 21, 2017 2:25 pm
by TMcD
dpayer wrote:
TMcD wrote:I'll start off by stating that I think NeoBook should have a datepicker built in.

Now my next question is how to go about it on my own... (I don't want to use a 3rd party plugin, since unfortunately, I don't want to rely on a 3rd party since most disappear and my app needs to remain solid.)

Thanks.


I created a function and a template you can use as a date picker. I use it in a couple of my apps.

I have a standalone demo but you can embed just the calendar on your page. See this page:

viewtopic.php?f=22&t=20140

Let me know if you need help implementing. It is all NB script an and NB objects.

Super nice. I'm gonna stick with my basic one I have created because it's not really needing to be that "pretty".. :lol: for now.

I still think there needs to be a default Date/Time picker within NeoBook. (I'll one day get around to my full request list.) :wink: