473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dynamic Select Drop Down, Difficulty Setting Options

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
9 2101
"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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Kingdom | last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the results. Choose a component type from the first drop down, lets say 'car' and the second box will list all the car...
6
by: Greg Scharlemann | last post by:
I am attempting to populate a drop down menu based on the selection of a different drop down menu. However, it is not working correctly, I cannot figure out for the life of me what exactly happens...
5
by: C White | last post by:
I'm trying to write an asp script that will create a series of drop lists based on a table like: canada ontario toronto street name link canada ontario toronto road...
1
by: Jeff Gardner | last post by:
Greetings: I have a table with 3 pieces of data that I would like to use to dynamically populate 3 drop downs using javascript. The fields are state, orgname, office. If it's not already...
5
by: jdzemke | last post by:
I am getting 'options' is null or not an object using when using a dynamic dataset with a dropdown list in an html form. I am filling-in a text field and filtering the values in the drop-down. ...
3
by: Michael McGrew | last post by:
I have a Dynamic drop-down box that is populated based on a ADO query. This works fine. I want to capture the users selection and assign it to a variable for use in another query. I am using the...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
1
by: bytesFTW99 | last post by:
I have been struggling with this for some time can anyone help out? just trying to have 3 dropdown boxes that fill depending on what is selected, then in some cases click a button and have the second...
3
by: azegurb | last post by:
hi I have just took from internet dinamic table. this table is dynamic and its rows dynamically can be increased. but i would like how create SUM function that automatically sums each added row...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.