473,772 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.le ngth = 30;
document.forms['testform'].day.options = thirtyDayMonth;
document.forms['testform'].day.selectedIn dex = 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 2127
"Adam" <bu************ **@gmail.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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************ *********@g47g2 000cwa.googlegr oups.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.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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************ *********@g47g2 000cwa.googlegr oups.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.javas cript FAQ - http://jibbering.com/faq
Aug 14 '05 #6
JRS: In article <cb************ ********@comcas t.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************ *********@g47g2 000cwa.googlegr oups.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.demo n.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.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************ ********@comcas t.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************ *********@g47g2 000cwa.googlegr oups.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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 16 '05 #8
JRS: In article <j5************ ********@comcas t.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.demo n.co.uk/> - FAQish topics, acronyms, & links.
For news:borland.*, use their server newsgroups.borl and.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************ ********@comcas t.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 "intelligen t 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.javas cript 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
2225
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 'manufacturers' and the display will then provide all the rest of the info from the other fields. I need to eliminate all the duplicates in the First Drop Down as it currently displays an entry for every record, many are identical, I might have over...
6
15418
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 because I am not getting any errors on the page. <html> <script language="javascript"> var phaseArray = new phaseArray(4); var phaseTypeId = new phaseTypeId(4); var phaseId = new phaseId(4);
5
1867
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 name link canada ontario hamilton road name link canada alberta calgary street name link canada alberta edmonton street name link usa new york buffalo street name link...
1
3593
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 obvious, I'd like orgname drop down to change when a state is selected and I would like office drop down to change when an orgname is selected. I can do this with multiple tables but am having difficulty getting it to work when the data is in the...
5
11959
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. This functionality works with a fixed set of values in the drop-down (i.e. <option value tags). Any insight would be greatly appreciated. <INPUT TYPE="text" NAME="input1" VALUE=""...
3
6832
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 onChange event to try and capture the users selection but it always passes the last entry in the drop-down list not what the user selects. Can anyone help me with this. I am very new to ASP\Jscript\Vbscript. A snippent of the code is below. ...
9
3628
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 to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I can't know what dynamic control I have to create.
1
3477
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 set of 3 dropdown boxes be filled with the same values. thank you <head> <SCRIPT LANGUAGE="JavaScript" type="text/javascript"> var firstChoice2 = 0; var secondChoice2 = 0;
3
4223
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 value (text value) here is the code if possible please help me Thanks beforehand <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.