Dynamically-generated option list?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles Packer

    Dynamically-generated option list?

    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

    mailboxATcpacke r.org
  • VK

    #2
    Re: Dynamically-generated option list?

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


    Comment

    • Charles Packer

      #3
      Re: Dynamically-generated option list?

      On Mar 12, 6:55 pm, VK <schools_r...@y ahoo.comwrote:
      On Mar 13, 12:34 am,Charles Packer<mail...@ cpacker.orgwrot e:
      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

      mailboxATcpacke r.org

      Comment

      • Charles Packer

        #4
        Re: Dynamically-generated option list?

        On Mar 13, 11:28 am, Charles Packer <mail...@cpacke r.orgwrote:
        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...N ow, 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

        mailboxATcpacke r.org

        Comment

        Working...