1 Reply Latest reply on Nov 1, 2015 1:38 PM by gkaiseril

    Multiple Groups of Perequisite checkboxes

    Oliver Parlett

      Hi, I have multiple groups of check boxes, but in each group i want to stop the user from filling out the check boxes on the right until the boxes on the left are true. I also want it so that if someone unchecks a box further the left the boxes to the right hide/lock and become false. I know I how to set the boxes to hide/lock based off the value and all that for each box individually, but with 58 groups and 250 check boxes doing this for each check box isn't viable.

       

      So far I've got this; but I have feeling it's completely wrong. new to javascript

       

      //create variables
      var i = 0;
      var v = event.target.value;
      
      //create and load array
      var fieldparent = this.getField("Ws");
      var fieldchildren = fieldparent.getArray();
      
      //get current field name
      var current = event.target.name;
      
      //find i
      for ( var L = 0; L < fieldchildren.length; L++){
          var cfieldname = fieldchildren[L].name;
          if ( current != null && current.name.match(cfieldname)) {
              i = L;
          }
      }
      
      //if box 0 is unchecked, then hide box 1 
      if (i != null && i == 0 && v == "false"){
          //hide all other boxes and uncheck
          for (var j = i+1; j < fieldchildren.length;j++){
              getField(fieldchildren[j]).display = v === "Off"?display.visible : display.hidden
              getField(fieldchildren[j]).value = "false";           
          }                
      }
      else { //otherwise behave normally
      
          if (i+1 != null && i+1 < fieldchildren.length){ //if next checkbox isn't out of bounds
              getField("fieldchildren" + [i+1]).display = v === "Off"?display.hidden : display.visible
              getField("fieldchildren" + [i+1]).value = "false";
              
              //check to see if two boxes to the right is in bounds, then for that box and boxes after hide and set to false
              if ( i+2 !=null &&  i+2 < fieldchildren.length){
                  for (var j = i+2; j < fieldchildren.length;j++){
                      getField(fieldchildren[j]).display = v === "Off"?display.visible : display.hidden
                      getField(fieldchildren[j]).value = "false";           
                      }
              }    
          }
      }
      
      

       

      Appreciate if anyone could help

        • 1. Re: Multiple Groups of Perequisite checkboxes
          gkaiseril MVP & Adobe Community Professional

          A form this complex and large will take careful planning. I would develop a naming strategy for the groups and fields within the group so one could use variables to identify the group and fields with the group. Also because the same type of action appears to apply to each group, I would look at creating a document level function for the process and you could pass the group's name to the function so you would know which group is being processed.

           

          You are aware that the responders do not get paid for the code and advice they provide.