shoebucket has asked for the wisdom of the Perl Monks concerning the following question:

I've seen it on various websites (www.logitech.com just for one), and I'm trying to duplicate the code for myself: how can I have a generated HTML form change its own input fields (dropdown menus, etc) based on the values of other input fields in the same form? I assume there will be a JavaScript function to reload the page with the current values intact, and make sure the .cgi (or .pl, whatever) that creates the form has a logic tree to check which input fields need to be displayed? Does anybody have a small snippet to get me started on that?
  • Comment on How can I create recursive dynamic forms?

Replies are listed 'Best First'.
Re: How can I create recursive dynamic forms?
by voyager (Friar) on Jun 08, 2001 at 17:55 UTC
    Doing what you ask will land you in the Jakob Nielsen Hall of Shame: having the UI change as it is being used can be disconcerting to a user ... think of Microsoft's "adaptive menus".

    Anyhow, you can change (for example) the contents of an HTML select when the value of some other field changes by having an onChange for an field that rewrites the content of the SELECT.options array for an HTML select tag.

    Notice this is client-side Javascript. No need to do anything on the server-side except send the Javascript with the served HTML.