Populating Select Lists

B

bryan.christina

This semester in school, I'm taking an Introduction to JavaScript class
online through my local community college. I'm having with an
assignment that requires you to set up two select lists. When you
select an option on the first list, it populates the second list with
specific information unique to that selection (Our example is to select
a state that would then populate a city list in the second). I can not
find any information or example to help with the script I need to
write, are there any suggestions?

Bryan
 
A

ASM

(e-mail address removed) a écrit :
This semester in school, I'm taking an Introduction to JavaScript class
online through my local community college. I'm having with an
assignment that requires you to set up two select lists. When you
select an option on the first list, it populates the second list with
specific information unique to that selection (Our example is to select
a state that would then populate a city list in the second). I can not
find any information or example to help with the script I need to
write, are there any suggestions?

You could try to find infos about new Option()

new Option(value, text)


Example with :
- selct = selector (dropdown list)
- list = array of items (fruits, materials, states, towns ...)

function fillSelect(selct, list) {
// to empty selector
selct.length = 0;
// new options
for (var i=0; i<list.length; i++)
{
// new option : value and text
var o = new Option(list, list)
// grow selector adding new option
selct[selct.length] = o;
}
}
 
S

Stephen Chalmers

to set up two select lists. When you
select an option on the first list, it populates the second list with
specific information unique to that selection (Our example is to select
a state that would then populate a city list in the second). I can not
find any information or example to help with the script I need to
write, are there any suggestions?

Where did you look? This homework question comes up so often that it's
difficult to avoid references to it.

Google: javascript +populate +"select box"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top