bebo
Newbie
Posts: 1
Registered: 11/3/2005
Location: Finland
Member Is Offline
|
| posted on 11/3/2005 at 09:50 AM |
|
|
Picking multiple dates
Hi Forum,
Has anyone implemented 'pick multiple dates' functionality? I would need it in my app. Ideally, selected dates would be presented in a text area or
something. Anyone?
All comments and examples are highly appreciated.
Thanks, Bebo
|
|
|
gillette101
Junior Member
Posts: 3
Registered: 12/26/2005
Member Is Offline
|
| posted on 12/26/2005 at 06:56 PM |
|
|
hi,
I found how to do that.
the original code is:
function cal_gen_date1 (dt_datetime) {
return (
(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "-"
+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "-"
+ dt_datetime.getFullYear()
);
}
modified is:
function cal_gen_date1 (dt_datetime) {
return (document.main.date.value+
(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "-"
+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "-"
+ dt_datetime.getFullYear()
);
}
where "main" in document.main.date.value...., is the name of the form in your web page. only the first line of the function is modified.
|
|
|
gillette101
Junior Member
Posts: 3
Registered: 12/26/2005
Member Is Offline
|
| posted on 12/27/2005 at 10:33 AM |
|
|
mmm....
after more serious tests, it doens't work if you take more than two dates...
any idea?
|
|
|
gillette101
Junior Member
Posts: 3
Registered: 12/26/2005
Member Is Offline
|
| posted on 12/27/2005 at 02:00 PM |
|
|
ok finally i got it.
two things to be fixed so as having in the target form several dates:
first, unicode is better than regexp expression, so:
// date generating function: EDITED
//modifié pour mettre plus d'une date
function cal_gen_date1 (dt_datetime) {
return ( document.main.date.value+
(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate() + "-"
+ (dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1) + "-"
+ dt_datetime.getFullYear()+'\u0020'
);
}
Note the \u0020 (space char in nuicode) instead of \r.
This solves a first error window.
second is the surprising error on time. i fixed that unactivating a function, just keeping the return value intsruction in it, and the declaration but
deleting evry thing else. That is the result (a big comment field):
// time parsing function: modifié pour permettre l'enregistrement de plusieurs dates EDITED
function cal_prs_time1 (str_time, dt_date) {
BEGINING OF COMMENT /*if (!dt_date) return null;
var arr_time = String(str_time ? str_time : '').split(':');*/
/*if (!arr_time[0]) dt_date.setHours(0);
else if (RE_NUM.exec(arr_time[0]))
if (arr_time[0] < 24) dt_date.setHours(arr_time[0]);
else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed range is 00-23.");
else return cal_error ("Invalid hours value: '" + arr_time[0] + "'.\nAllowed values are unsigned integers.");
if (!arr_time[1]) dt_date.setMinutes(0);
else if (RE_NUM.exec(arr_time[1]))
if (arr_time[1] < 60) dt_date.setMinutes(arr_time[1]);
else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed range is 00-59.");
else return cal_error ("Invalid minutes value: '" + arr_time[1] + "'.\nAllowed values are unsigned integers.");
if (!arr_time[2]) dt_date.setSeconds(0);
else if (RE_NUM.exec(arr_time[2]))
if (arr_time[2] < 60) dt_date.setSeconds(arr_time[2]);
else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed range is 00-59.");
else return cal_error ("Invalid seconds value: '" + arr_time[2] + "'.\nAllowed values are unsigned integers.");
dt_date.setMilliseconds(0);*////END OF COMMENT
return dt_date;
}
|
|
|