techutopia
Total posts: 202
05 Sep 2016 10:26

Hi all,

I am planning a date selector ...

So, I would create the field dropdowns:

The century The year The month The day

Depending on which 'century' the user selects, I would like to update the 'year' with availiable options. e.g. 21st century = 2001 -> 2100

Depending on which 'month' the user selects, I would like to update the 'day' with availiable options. e.g. February = 1 -> 28

If you could advise me on the easiest way to do this it would be much appreciated.

Thanks,

Dale.

Last Modified: 02 Sep 2021


pepperstreet VIP
Total posts: 3,837
05 Sep 2016 22:51

Just some thoughts...

techutopia e.g. February = 1 -> 28

Hello, do you need an exact date/days calculation? That would require a calendar script, IMHO.

The cobalt date & time field has simple-select input, but does not supply a cascading "step-by-step" method. I think your mentioned "century" or "decades" are not available in the underlying script. I believe you can set an option during initialization to start with years only... and then click/drill down through months and then days. I have seen a parameter startView in the original script.


Probably it makes sense to use another Date/Time script. For instance: Bootstrap DatePicker
By default it has no cascading selects, but it offers "century" and more as starting view
Unfortunately you would still have a Calendar/Date Picker style.


Not sure, but if a script offers "events", "callbacks" and "theming",
it might allow to create a different output style and also update those elements...


If you would not need the exact days calculation... and there would be a more limited amount of options and values... it could be solved by the Multiple-Level-Select field.

May I ask what the use case and purpose is?


techutopia
Total posts: 202
06 Sep 2016 09:43

Hi pepperstreet,

Good to 'see' you again here, I've been away from Cobalt for a few years.

Hello, do you need an exact date/days calculation? That would require a calendar script, IMHO.

The products I am trying to list have a 'creation' date, but this date is vague and sometimes not exactly known. As an example, think of an old painting, someone may know it was created in the 1500's, but not the exact date. But for more recent paitnings, a century, year, month and date might be known.

Probably it makes sense to use another Date/Time script. For instance: Bootstrap DatePicker

By default it has no cascading selects, but it offers "century" and more as starting view

Unfortunately you would still have a Calendar/Date Picker style.

I don't mind a datepicker, though when you start it on century mode, it's quite unintitive to the user as to what it is doing. And whilst it does return a value, it is not seperate to allow customer searching with individual cobalt fields later with ease.

One option is to have a restricted datepicker for each field - century, year, month, date - but again these would be need to be chained.

If you would not need the exact days calculation... and there would be a more limited amount of options and values... it could be solved by the Multiple-Level-Select field.

I won't actually have a limited amount of options and values I'm afraid due to the date ranages involved.

Thanks again,

Dale.


pepperstreet VIP
Total posts: 3,837
06 Sep 2016 17:15

Hello Dale,

techutopia One option is to have a restricted datepicker for each field - century, year, month, date -

Not a bad idea, if you have several different and even incomplete data, you would have to deal with it in a special way...

If the input is one date field you would have to parse the final input and store the elements separatly,
or the other way around: Split the inputs, store them, and maybe construct a complete date in an extra field.
Either way would give more fine-grained filter options.

but again these would be need to be chained.

It depends, IMHO. If it is a "real" and complete date info, then yes.
But what happens if you enter a partial info... you would have to "zero/reset" the unused date parts.

Powered by Cobalt