Dynamic Select Drop Down, Difficulty Setting Options

A

Adam

Hey,

I'm trying to write a script with two standard drop down boxes. One
contains days one contains the month. I want to update the options in
the days box everytime the month is changed... i.e select August, and
days are filled up to 31, select September and only 30. The part where
I am having difficulty is that after the onChange event has triggered
and I have checked what the new month is, filling the box with relevant
values is tricky...

At the Start....
thirtyDayMonth = new Array(new Option('1','1'), new Option('2','2'),
.... etc


Once a specific month is selected...

document.forms['testform'].day.options.length = 30;
document.forms['testform'].day.options = thirtyDayMonth;
document.forms['testform'].day.selectedIndex = SelectedDay;

I am a bit of a newbie to JS, but I assume its OK to have an array of
"arrays" (options really).

Basically, I can never write any values to the options. Changing the
length does work.

According to Firefox I am "setting a property that has only a
getter"??? Does this mean read only or what? IE gives me an even less
usefull error msg for the same line.

Does anyone have any suggestions please?
Any help much appreciated...


Cheers,

AdamK
 
M

McKirahan

Adam said:
Hey,

I'm trying to write a script with two standard drop down boxes. One
contains days one contains the month. I want to update the options in
the days box everytime the month is changed... i.e select August, and
days are filled up to 31, select September and only 30. The part where
I am having difficulty is that after the onChange event has triggered
and I have checked what the new month is, filling the box with relevant
values is tricky...

[snip]

And what if the day is selected first?
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Fri, 12 Aug 2005 08:05:46, seen in Adam
I'm trying to write a script with two standard drop down boxes. One
contains days one contains the month. I want to update the options in
the days box everytime the month is changed... i.e select August, and
days are filled up to 31, select September and only 30. The part where
I am having difficulty is that after the onChange event has triggered
and I have checked what the new month is, filling the box with relevant
values is tricky...

And how long is February?

You should have read the newsgroup FAQ, which would have enabled you to
locate one answer. See foot of this, and js-date6.htm#YMD.

Note that it may be well to adjust the HTML so that full-length selects
are presented to those without javascript.


McKirahan : Obviously, in specifying a date, one should specify the
year, month, and day in that order; and the page should be laid out to
encourage that. However, if one insists on having the day first, then
one can no doubt set the months control to contain only those months
having the selected day.
 
A

Adam

If the day is selected first, that is no problem. The selected value
would remain in the days box, unless for example someone selects day 29
and then month february. I will then prob bring up an alert msg.

That is not really the problem though... I was wondering if anyone knew
why I can't seem to assign the array of options straight to the select
box. the options property is just an array of options as far as I'm
aware.

Cheers,

Adam
 
A

Adam

Thanks, your link does seem to solve the problem. I hadn't seen an FAQ
mentioned anywhere else, either way I don't think my original question
has been that frequently asked!

Cheers both of you for your time...

Adam
 
R

Randy Webb

Dr John Stockton said the following on 8/13/2005 10:11 AM:
JRS: In article <[email protected]>,
dated Fri, 12 Aug 2005 08:05:46, seen in Adam



And how long is February?

You should have read the newsgroup FAQ, which would have enabled you to
locate one answer. See foot of this, and js-date6.htm#YMD.

One who likes to claim "The subject line is not always visible"
shouldn't allude to a foot that is not always visibile.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Sun, 14 Aug
2005 18:41:16, seen in Randy Webb
Dr John Stockton said the following on 8/13/2005 10:11 AM:

I uttered nothing AFAIR; certainly nothing audible to you.
One who likes to claim "The subject line is not always visible"
shouldn't allude to a foot that is not always visibile.



It was because the foot is not always visible that I referred to its
contents thus. Independently of my sigs, he should have read the FAQ.

Note that in English, "should" can be used to refer to a moral duty, or
to a course of action that, as it happened, would have been better.
 
R

Randy Webb

Dr John Stockton in a fit of morning caffeine withdrawals posted the
following on 8/15/2005 3:02 PM:
JRS: In article <[email protected]>, dated Sun, 14 Aug
2005 18:41:16, seen in Randy Webb



I uttered nothing AFAIR; certainly nothing audible to you.

Your sense of reality continues to give me my morning laughs.
It was because the foot is not always visible that I referred to its
contents thus. Independently of my sigs, he should have read the FAQ.

And without the foot visibile, the only thing that is visibile would be
to "See js-date.htm#YMD" which when put in my browser gives a page not
found as it should. URL's in Usenet should be absolute.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Tue, 16 Aug
2005 11:41:32, seen in Randy Webb
And without the foot visibile, the only thing that is visibile would be
to "See js-date.htm#YMD" which when put in my browser gives a page not
found as it should. URL's in Usenet should be absolute.

If the foot is not visible, then the intelligent reader, on seeing "See
foot of this" will use the obvious means to do so, after which the next
moves are clear enough. Since the foot of an article is part of the
body of an article, it will be so shown by any reasonable software.
Other sorts of reader are unlikely to find the thus-indicated advice
useful, anyway.

js-date.htm#YWD is not a URL - and neither is it what I put.

Your spelling-checker is broken.
 
R

Randy Webb

Dr John Stockton said the following on 8/16/2005 3:42 PM:
JRS: In article <[email protected]>, dated Tue, 16 Aug
2005 11:41:32, seen in Randy Webb



If the foot is not visible, then the intelligent reader, on seeing "See
foot of this" will use the obvious means to do so, after which the next
moves are clear enough.

And the intelligent reader, after seeing a question posed in the subject
line but not the body, will use the "obvious means to do so" to see it
to be able to answer the question. Is it 6 of one or a half dozen of the
other?

Since the foot of an article is part of the body of an article, it will
be so shown by any reasonable software. Other sorts of reader are unlikely
to find the thus-indicated advice useful, anyway.

js-date.htm#YWD is not a URL - and neither is it what I put.

Ooops, Its a file name, which you indicated to the OP to peruse for
useful information. Please tell me, how the hell would they read it
without an URL to get to it? Or, does the "intelligent reader" use the
means to do so?

You never cease to amaze me with your pedantics.
Your spelling-checker is broken.

No, it is not broken. You just think it is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top