From: bruce on
On May 5, 1:12 pm, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk>
wrote:
> In comp.lang.javascript message <4a61d8ae-e333-4849-962a-9f68f7092b78(a)d1
> 9g2000yqf.googlegroups.com>, Tue, 4 May 2010 11:56:12, bruce
> <bruc...(a)bellsouth.net> posted:
>
>
>
> >You are correct. The solution to my problem was easy. 4 lines of
> >code..
>
> If you were to post that code,
> either    it might be helpful to others
> or        we could tell you of its faults.

Sure. I'd be especially interested in its faults.

Invocation is via an onChange event
<snip>
<select name="month" id="month" size="1"
onchange="setDayBox(document.Reservation.month.options[document.Reservation.month.selectedIndex].value);">

/* ******************************************************** */
/* setDayBox */
/* Change the number of days in the Day drop down box to */
/* reflect the number of days in the selected month. */
/* Input argument: */
/* chosen: Selected month (1 to 12) */
/* ******************************************************** */

function setDayBox(chosen) {

var numberOfDays = selectNumberOfDaysInMonth(parseInt(chosen));

var dayBox = document.Reservation.Day;
dayBox.options.length = 0;

for(i=0; i < numberOfDays; i++) {

dayBox.options[dayBox.options.length] = new Option(i
+1,i,false,false);

}
}

</snip>


>
> <URL:http://www.merlyn.demon.co.uk/js-date6.htm> needs more than 4
> lines, IIRC.
>
> But the whole thing is much easier in HTML 5, where appropriately
> implemented : <URL:http://www.merlyn.demon.co.uk/js-date3.htm#HTML>.
>
> --
>  (c) John Stockton, nr London UK. ?...@merlyn.demon.co.uk  BP7, Delphi 3 & 2006.
>  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
>  <URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
>  NOT <URL:http://support.codegear.com/newsgroups/>: news:borland.* Guidelines

From: Garrett Smith on
bruce wrote:
> On May 5, 1:12 pm, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk>
> wrote:
>> In comp.lang.javascript message <4a61d8ae-e333-4849-962a-9f68f7092b78(a)d1
>> 9g2000yqf.googlegroups.com>, Tue, 4 May 2010 11:56:12, bruce
>> <bruc...(a)bellsouth.net> posted:

[snip]

("snip" explained here <http://jibbering.com/faq/#reply>)

> Sure. I'd be especially interested in its faults.
>
> Invocation is via an onChange event
> <snip>
> <select name="month" id="month" size="1"
> onchange="setDayBox(document.Reservation.month.options[document.Reservation.month.selectedIndex].value);">
>

Accessing form controls the nonstandard way, as you have, has known side
effects. The most obvious is that if the control is orphaned from the
document after it has been accessed off the form, it remains as a
property of the form, even if there are no other references pointing to it.

To correctly access a form control, please see:
<http://jibbering.com/faq/#formControlAccess>

> /* ******************************************************** */
> /* setDayBox */
> /* Change the number of days in the Day drop down box to */
> /* reflect the number of days in the selected month. */
> /* Input argument: */
> /* chosen: Selected month (1 to 12) */
> /* ******************************************************** */
>
> function setDayBox(chosen) {
>
> var numberOfDays = selectNumberOfDaysInMonth(parseInt(chosen));
>

It is a good idea to be in the habit of using a radix with parseInt.

<http://jibbering.com/faq/#parseIntBase>

> var dayBox = document.Reservation.Day;
> dayBox.options.length = 0;
>
> for(i=0; i < numberOfDays; i++) {
>

Don't forget var.

> dayBox.options[dayBox.options.length] = new Option(i
> +1,i,false,false);
>
> }
> }
>

The strategy employed sets dayBox to numberOfDays each time a month is
selected. That is not a very efficient approach.

Instead, when the selected month contains less than 31 days, why not
disable the days from the end of the month. That way a js-disabled user
(such as myself), has the ability to use it.

Rough outline:

// untested.
function adjustDaysForDate(selectedMonth, selectedYear) {
var daysInMonth = getDaysInMonth(selectedMonth, selectedYear);
var disabledDays = 31 - daysInMonth;
if(disabledDays) {
disableInvalidDays(disabledDays);
}
}

function disableInvalidDays(count) {
for(var i = 0; i < count; i++) {
daySelectElement.options[30-i].disabled = true;
}
}

function getDaysInMonth(month, year) {
// etc.
}
[snip]

[snip Stockton's sig]
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: bruce on
On May 6, 3:04 am, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
> bruce wrote:
> > On May 5, 1:12 pm, Dr J R Stockton <reply1...(a)merlyn.demon.co.uk>
> > wrote:
> >> In comp.lang.javascript message <4a61d8ae-e333-4849-962a-9f68f7092b78(a)d1
> >> 9g2000yqf.googlegroups.com>, Tue, 4 May 2010 11:56:12, bruce
> >> <bruc...(a)bellsouth.net> posted:
>
> [snip]
>
> ("snip" explained here <http://jibbering.com/faq/#reply>)
>
> > Sure. I'd be especially interested in its faults.
>
> > Invocation is via an onChange event
> > <snip>
> > <select name="month" id="month" size="1"
> > onchange="setDayBox(document.Reservation.month.options[document.Reservation.month.selectedIndex].value);">
>
> Accessing form controls the nonstandard way, as you have, has known side
> effects. The most obvious is that if the control is orphaned from the
> document after it has been accessed off the form, it remains as a
> property of the form, even if there are no other references pointing to it.
>
> To correctly access a form control, please see:
> <http://jibbering.com/faq/#formControlAccess>
>
> > /* ******************************************************** */
> > /* setDayBox                                                */
> > /*    Change the number of days in the Day drop down box to */
> > /*    reflect the number of days in the selected month.     */
> > /* Input argument:                                          */
> > /*    chosen: Selected month (1 to 12)                      */
> > /* ******************************************************** */
>
> > function setDayBox(chosen) {
>
> >   var numberOfDays = selectNumberOfDaysInMonth(parseInt(chosen));
>
> It is a good idea to be in the habit of using a radix with parseInt.
>
> <http://jibbering.com/faq/#parseIntBase>
>
> >   var dayBox = document.Reservation.Day;
> >   dayBox.options.length = 0;
>
> >   for(i=0; i < numberOfDays; i++) {
>
> Don't forget var.
>
> >      dayBox.options[dayBox.options.length] = new Option(i
> > +1,i,false,false);
>
> >    }
> > }
>
> The strategy employed sets dayBox to numberOfDays each time a month is
> selected. That is not a very efficient approach.
>
> Instead, when the selected month contains less than 31 days, why not
> disable the days from the end of the month. That way a js-disabled user
> (such as myself), has the ability to use it.
>
> Rough outline:
>
> // untested.
> function adjustDaysForDate(selectedMonth, selectedYear) {
>    var daysInMonth = getDaysInMonth(selectedMonth, selectedYear);
>    var disabledDays = 31 - daysInMonth;
>    if(disabledDays) {
>      disableInvalidDays(disabledDays);
>    }
>
> }
>
> function disableInvalidDays(count) {
>    for(var i = 0; i < count; i++) {
>      daySelectElement.options[30-i].disabled = true;
>    }
>
> }
>
> function getDaysInMonth(month, year) {
>    // etc.}
>
> [snip]
>
> [snip Stockton's sig]
> --
> Garrett
> comp.lang.javascript FAQ:http://jibbering.com/faq/

Garrett:

Thanks for the "education." I will use what you have suggested, once
I understand it.

Thanks again..

Bruce
From: Dr J R Stockton on
In comp.infosystems.www.authoring.html message <dec9497a-d056-43db-8ddb-
2c3eb1eb1d60(a)j33g2000yqn.googlegroups.com>, Wed, 5 May 2010 04:00:13,
bruce <bruceaj(a)bellsouth.net> posted:
>On May 5, 5:08�am, Gregor Kofler <use...(a)gregorkofler.com> wrote:
>> Am 2010-05-04 18:18, Dr J R Stockton meinte:
>>
>> > How about those whose date of birth was 1900-02-29? �Some may still be
>> > alive.

>No one was ever born on 1900-02-29 as 1900 is not a leap year. 2000
>was the a leap year and the first TIME the divide by 400 rule was ever
>used. So we know they are not at the tennis courts. Maybe at the
>Cabana enjoying a cool one!!

Naive.

It seems likely that a few hundred Greeks were born on that date; Greece
was then using the Julian Calendar, as were several other Eastern
European countries including Russia.

The small American Olympic team is said to have nearly missed the first
Games (Athens, 1896), as the Greeks had given Julian dates.

The Imperial Russian Olympic Team, using the Julian Calendar, is said
to have arrived twelve days too late for the 1908 London Games (there is
reason to doubt this).


Also, the divide by 400 rule was used in 1600; the Gregorian Calendar
was in use in parts of Europe from 1582.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
From: Dr J R Stockton on
In comp.infosystems.www.authoring.html message <no.email-D4049A.09204005
052010(a)news1.chem.utoronto.ca>, Wed, 5 May 2010 09:20:41, David Stone
<no.email(a)domain.invalid> posted:
>In article <Fs+ANRLkjE4LFw1J(a)invalid.uk.co.demon.merlyn.invalid>,
> Dr J R Stockton <reply1018(a)merlyn.demon.co.uk> wrote:
>[snip]

>Around here,

Those who write "around here" without giving in the body of the message
a reasonably clear indication of approximately where "here" is are
likely to be assumed to be, or treated as, Americans.

> For the limited number of those of the second
>case, I believe they would normally give their names for personal
>use as Elizabeth Windsor, etc.

My understanding is that, while possible, that id rarely done, at least
in the case of E II R.

>> And those whose date of birth does not match their birthday?
>
>The only living example I can think of has two "birthdays", the
>real one and the officially celebrated one, so no real conflict.
>Of course, you still have a sizeable number who don't know what
>their real date of birth is...

You have forgotten her Consort, born in 1921.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 7.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
MiniTrue is good for viewing/searching/altering files, at a DOS / CMD prompt;
free, DOS/Win/UNIX, new via <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.