Connecting Tech Pros Worldwide Help | Site Map

Dynamically-generated option list?

Charles Packer
Guest
 
Posts: n/a
#1: Mar 12 '08
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.

--
Charles Packer
http://cpacker.org/whatnews
mailboxATcpacker.org
VK
Guest
 
Posts: n/a
#2: Mar 13 '08

re: Dynamically-generated option list?


On Mar 13, 12:34 am, Charles Packer <mail...@cpacker.orgwrote:
Quote:
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/

Charles Packer
Guest
 
Posts: n/a
#3: Mar 13 '08

re: Dynamically-generated option list?


On Mar 12, 6:55 pm, VK <schools_r...@yahoo.comwrote:
Quote:
On Mar 13, 12:34 am,Charles Packer<mail...@cpacker.orgwrote:
Quote:
I need to present a list of options in dropdown list B
based on what the user selected in dropdown list A.

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.

--
Charles Packer
http://cpacker.org/whatnews
mailboxATcpacker.org
Charles Packer
Guest
 
Posts: n/a
#4: Mar 13 '08

re: Dynamically-generated option list?


On Mar 13, 11:28 am, Charles Packer <mail...@cpacker.orgwrote:
Quote:
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...

--
Charles Packer
http://cpacker.org/whatnews
mailboxATcpacker.org
Closed Thread