Dependency Fields Manager

Use this script to manage the dependency fields on your web, meaning you can hide/display some fields by changing values of others; not meant to replace your server scripting process. Please preview the script and read document.




Over 2000+ free Javascript
at JavaScriptBank.com Website
Sampled by JavaScriptBank.com


An overview of this script:

  • All dependency logic is defined via the class attribute inside the form fields in question, for easy implementation.
  • Create dependency based on the value (ie: text fields) or state (ie: radio boxes) of another field. Use "OR" or "AND" to create more complex dependencies.
  • Degrades well with browsers that have JavaScript disabled.

This is an example web hosting signup form. It offers options of Windows or Linux hosting. If Windows, the client can choose Apache or IIS, and optional frequent crashes. If the client decides that s/he wants IIS, s/he has the option of ASP, and insecurity. The alternative is Apache, which is also available on Linux, as is SSH access. Obviously, the client cannot choose two webserver packages. It also gives an example of how to hide text using a label and hidden form element, and how to depend on a variable-value element.

More info

The script uses a simple syntax to implement dependency amongst form fields, by utilising the class attribute. There are two basic types of statements:

DEPENDS ON name [BEING value] [OR name [BEING value]]

CONFLICTS WITH name [BEING value]

Multiple statements can be separated with the "AND" keyword. "AND" can also be used to mark the boundary between these statements and true CSS classes, so the script doesn't interfere with your stylesheets. There is also a special keyword for use after BEING: EMPTY.