Skip to content Skip to sidebar Skip to footer

Enabling Inactive Fields By Clicking On Field

Is it possible to have a group of inactive fields where if one of the fields is clicked some of the fields become mandatory and some segments of code are run? Say for example you h

Solution 1:

This method you are looking is called 'chained-select' method.

jQuery framework is used for example below:

<html><head><scriptsrc="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script></head><body><formaction=""method="get"><label><inputname="Government"type="checkbox"value="">Government</label><br><label><inputname="Parent"type="checkbox"id="parent_child_group"value="">Parent</label><br><label>Name of Child
    <inputtype="text"name="parent_child"value=""class="parent_child_group"></label><br><label>Other
    <inputtype="text"name="parent_other"value=""class="parent_child_group"></label></form><scripttype="text/javascript">
    $(document).ready(function () {
         $(function() {
             enable_cb();
             $("#parent_child_group").click(enable_cb);
         });

         functionenable_cb() {
             if (this.checked) {
                 $("input.parent_child_group").removeAttr("disabled");
             } else {
                 $("input.parent_child_group").attr("disabled", true);
             }
         }
    });        
    </script></body></html>

Working example on JSFiddle: http://jsfiddle.net/farondomenic/fg7p8/1/

Post a Comment for "Enabling Inactive Fields By Clicking On Field"