James L.
08-28-2004, 12:31 AM
Hey all,
I have searched the forums, but have not adequately figured out what I am after. Truth be told I am not sure why this isn't clicking for me, as it shouldn't be that hard.
I have a form with two select elements (drop down menus). I am looking to have the contents of one change based on the selection of the other. So, for example:
Menu one is COUNTRY, with the following two options:
Canada
America
Menu two is PROVINCE/STATE, and will change dynamically based on the selection in menu one. So, if menu one read:
COUNTRY: Canada
Menu two (PROVINCE/STATE) would list:
British Columbia
Alberta
Manitoba
Ontario
...etc
If menu one was changed to read:
COUNTRY: America
Menu two (PROVINCE/STATE) would change dynamically to read:
Arizona
California
New Jersey
Detroit
...etc
Now, I know I will need an "onchange()" event handler in menu one (the COUNTRY menu), so when it is changed menu two (the PROVINCE/STATE) changes its contents from the provinces to the states.
I am just not sure how to set up the select elements in the form. For example, If I set it to the Provinces in the html side of things, I know I can access those elements using an array from within Javascript. I am guessing I could change the value of each select option, but one list would be 13 items long (the provinces), while the other would be 51 items long (the states).
Any help would be greatly appreciated!
Cheers,
James
I have searched the forums, but have not adequately figured out what I am after. Truth be told I am not sure why this isn't clicking for me, as it shouldn't be that hard.
I have a form with two select elements (drop down menus). I am looking to have the contents of one change based on the selection of the other. So, for example:
Menu one is COUNTRY, with the following two options:
Canada
America
Menu two is PROVINCE/STATE, and will change dynamically based on the selection in menu one. So, if menu one read:
COUNTRY: Canada
Menu two (PROVINCE/STATE) would list:
British Columbia
Alberta
Manitoba
Ontario
...etc
If menu one was changed to read:
COUNTRY: America
Menu two (PROVINCE/STATE) would change dynamically to read:
Arizona
California
New Jersey
Detroit
...etc
Now, I know I will need an "onchange()" event handler in menu one (the COUNTRY menu), so when it is changed menu two (the PROVINCE/STATE) changes its contents from the provinces to the states.
I am just not sure how to set up the select elements in the form. For example, If I set it to the Provinces in the html side of things, I know I can access those elements using an array from within Javascript. I am guessing I could change the value of each select option, but one list would be 13 items long (the provinces), while the other would be 51 items long (the states).
Any help would be greatly appreciated!
Cheers,
James