Dynamically-generated option list?

C

Charles Packer

I need to present a list of options in dropdown list B
based on what the user selected in dropdown list A.
Both A and B content will be generated dynamically from
a database, similar to the way http://cars.com lets the user
select the make of a car, which in turn populates a list
of models. (That site itself is no help, since the
relevant functions don't appear in the source of the page.)

A URL of an appropriate Javascript tutorial or example
would be welcome. The tutorials I've found so far use
static option lists. I guess what I really need is to
see how an option list can be generated dynamically.
I've tried Googling for Javascript tutorials containing
"onChange", but haven't found anything useful yet.
 
V

VK

I need to present a list of options in dropdown list B
based on what the user selected in dropdown list A.
Both A and B content will be generated dynamically from
a database, similar to the wayhttp://cars.comlets the user
select the make of a car, which in turn populates a list
of models. (That site itself is no help, since the
relevant functions don't appear in the source of the page.)

A URL of an appropriate Javascript tutorial or example
would be welcome. The tutorials I've found so far use
static option lists. I guess what I really need is to
see how an option list can be generated dynamically.
I've tried Googling for Javascript tutorials containing
"onChange", but haven't found anything useful yet.

http://www.javascripttoolbox.com/lib/dynamicoptionlist/
 
C

Charles Packer



Thanks. This seems to be exactly what I need for the
basic mechanics, but I need to access a database to re-populate the
child list each time the user selects a different option from the
parent list. I've learned through some Googling that Javascript
doesn't support SQL directly. I infer, however, that I can have a
Javascript function execute an external Perl script that would do the
SQL and return the results, though I haven't found
a tutorial/example yet that shows how to execute an
external program.
 
C

Charles Packer

doesn't support SQL directly. I infer, however, that I can have a
Javascript function execute an external Perl script that would do the
SQL and return the results, though I haven't found
a tutorial/example yet that shows how to execute an
external program.

Oops! I've gone through enough of one of the Javascript
tutorials at this point to see that, because Javascript
is client-side and Perl is server-side, it implies
an action -- however it is coded -- that will be just
like hitting a URL to get my new list content each time.
Sounds inefficient...Now, since I'll be generating the
page itself via a CGI call, I guess I could generate
all the possible lists (46 child lists of, at most,
a dozen entries each) as static Javascript code as part of that page.
Wish me luck...
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top