Dynamic Select Drop Down, Difficulty Setting Options
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Dynamic Select Drop Down, Difficulty Setting Options

From: Adam <budgieofdarkness@gmail.com>
Date: Fri Aug 12 2005 - 17:05:46 CEST

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
Received on Tue Oct 18 03:08:14 2005