By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,651 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,651 IT Pros & Developers. It's quick & easy.

Dynamic Select Drop Down, Difficulty Setting Options

P: n/a
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

Aug 12 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
"Adam" <bu**************@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
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?
Aug 12 '05 #2

P: n/a
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

Aug 13 '05 #3

P: n/a
JRS: In article <11*********************@g47g2000cwa.googlegroups. com>,
dated Fri, 12 Aug 2005 08:05:46, seen in news:comp.lang.javascript, Adam
<bu**************@gmail.com> posted :
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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 13 '05 #4

P: n/a
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

Aug 14 '05 #5

P: n/a
Dr John Stockton said the following on 8/13/2005 10:11 AM:
JRS: In article <11*********************@g47g2000cwa.googlegroups. com>,
dated Fri, 12 Aug 2005 08:05:46, seen in news:comp.lang.javascript, Adam
<bu**************@gmail.com> posted :

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.


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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Aug 14 '05 #6

P: n/a
JRS: In article <cb********************@comcast.com>, dated Sun, 14 Aug
2005 18:41:16, seen in news:comp.lang.javascript, Randy Webb
<Hi************@aol.com> posted :
Dr John Stockton said the following on 8/13/2005 10:11 AM:


I uttered nothing AFAIR; certainly nothing audible to you.
JRS: In article <11*********************@g47g2000cwa.googlegroups. com>,
dated Fri, 12 Aug 2005 08:05:46, seen in news:comp.lang.javascript, Adam
<bu**************@gmail.com> posted :
I'm trying to write a script with two standard drop down boxes. One
contains days one contains the month.
...
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.


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.

--
John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Aug 15 '05 #7

P: n/a
Dr John Stockton in a fit of morning caffeine withdrawals posted the
following on 8/15/2005 3:02 PM:
JRS: In article <cb********************@comcast.com>, dated Sun, 14 Aug
2005 18:41:16, seen in news:comp.lang.javascript, Randy Webb
<Hi************@aol.com> posted :
Dr John Stockton said the following on 8/13/2005 10:11 AM:

I uttered nothing AFAIR; certainly nothing audible to you.


Your sense of reality continues to give me my morning laughs.
JRS: In article <11*********************@g47g2000cwa.googlegroups. com>,
dated Fri, 12 Aug 2005 08:05:46, seen in news:comp.lang.javascript, Adam
<bu**************@gmail.com> posted :
I'm trying to write a script with two standard drop down boxes. One
contains days one contains the month.
...
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.


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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 16 '05 #8

P: n/a
JRS: In article <j5********************@comcast.com>, dated Tue, 16 Aug
2005 11:41:32, seen in news:comp.lang.javascript, Randy Webb
<Hi************@aol.com> posted :
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.


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.


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.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
For news:borland.*, use their server newsgroups.borland.com ; but first read
Guidelines <URL:http://www.borland.com/newsgroups/guide.html> ff. with care.
Aug 16 '05 #9

P: n/a
Dr John Stockton said the following on 8/16/2005 3:42 PM:
JRS: In article <j5********************@comcast.com>, dated Tue, 16 Aug
2005 11:41:32, seen in news:comp.lang.javascript, Randy Webb
<Hi************@aol.com> posted :
>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.

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.

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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 16 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.