View Full Version : Form Dependency Manager & Checkbox set

10-08-2010, 10:05 PM
I originally posted in the scripts help, however, I don't think the author of this script is around any longer and there appears to be no support for it at all. I'm hoping someone in this form might be able to help me out a bit.

1) CODE TITLE: Form Dependency Manager
3) DESCRIPTION: Show/Hide form elements depending on other selections.
4) URL TO CODE: http://www.dynamicdrive.com/dynamicindex16/formdependency.htm

I've forms on my site which have checkbox sets which are named "checkboxname[]" so the values are passed to PHP in an array. When using the form dependency manager, the only way that sub-fields are displayed is if ALL the checkboxes are selected or if only the ones that have sub-selections to show are checked.

Here are the first set of checkboxes:

<label for="comptype1"><input id="comptype1" type="checkbox" name="comptype[]" value="COMP" class="DEPENDS ON type BEING COMP">Completes Data <sup style="color:#C02020;">1</sup><br></label>
<label for="comptype2"><input id="comptype2" type="checkbox" name="comptype[]" value="INS" class="DEPENDS ON type BEING COMP">INS Clears<br></label>
<label for="comptype3"><input id="comptype3" type="checkbox" name="comptype[]" value="OOS" class="DEPENDS ON type BEING COMP">OOS Clears<br></label>
<label for="comptype5"><input id="comptype5" type="checkbox" name="comptype[]" value="DET" class="DEPENDS ON type BEING COMP">Detailed Orders<br></label>

This is a set where the user can select one or any combination of items. The sub-set of checkboxes is below:

<label for="techtype1"><input id="techtype1" type="checkbox" name="techtype[]" value="ONE" class="DEPENDS ON comptype[] BEING DET OR comptype[] BEING COMP">ONE<br></label>
<label for="techtype2"><input id="techtype2" type="checkbox" name="techtype[]" value="TWO" class="DEPENDS ON comptype[] BEING DET OR comptype[] BEING COMP">TWO<br></label>

These two items above should appear ANY time that either Completes Data AND/OR Detailed Orders is checked. However it does not work that way.

If ALL are checked, the second set of checkboxes appears.
If I uncheck either completes OR detailed orders, the second set of checkboxes disappears - even though one of the items that requires that set is still checked.

Is there a way to modify the show/hide so that if a selected value is checked inside an array of checkboxes, the sub-set will display/not display as desired?

Also, is there a way to tell another sub-set of checkboxes to appear only if one of the previous ones has been checked? Kind of like saying CONFLICTS with fieldname BEING EMPTY except for checkboxes?

Any help is appreciated.