You are viewing limited content. For full access, please sign in.

Question

Question

Checklist in Forms - only want selected items to stay visible

asked on July 30, 2016

I have set up a form with a checklist that contains 34 violations.  I want the inspector to be able to select only the violations that pertain to the inspection being done, and have the ones not selected hidden.

Extremely new to Forms so bear with me please.

Thanks for any help.

Christine

 

0 0

Replies

replied on August 2, 2016

Here's what the entire thing  should look like:

$(document).ready(function (){
  if ($("#Field35-0").is(':checked')){
   var picks = $('.toDoList input').length-1;
   for(i = 0; i < picks; i++) {
           if($('#Field18-' + i).is(':checked')) {
              $('#Field18-' + i).show('fast');
             } else {
               $('#Field18-' + i).parent().hide('slow');
             }
          }
       }
  
       $('#Field35-0').click(function(hideStuff){
           var choices = $('.toDoList input').length-1;
             for(i = 0; i < choices; i++) {
           if($('#Field18-' + i).is(':checked')) {
              $('#Field18-' + i).show('fast');
           } else {
             $('#Field18-' + i).parent().hide('slow');
           }
        }
        });
  });

 

1 0
replied on October 27, 2016

Thank you Rick,

I will give this a try.  Do I insert the code as line items in my checklist above what is currently there?

Christine

0 0
replied on October 27, 2016

Christine,

 

No, just take off the top and bottom line if you already have the (document).ready function in the javascript section of the form.  Then you can copy the code above into your javascript section at the top or the bottom, doesn't matter, as long as you are not in between the curly braces of another function.

0 0
replied on August 2, 2016

Christine,

I have some code ready for you to do what you wanted, it's just not persisting yet from page reloads.  Somebody else will hopefully help you with that, but if not I'm still working on it.  This code removes all the entries not selected, you would just need to add a separate checkbox or radio button to have the user click so you know when they are done selecting checkboxes.  This is the 'Field35-0' in the code, just change that to whatever the trigger checkbox is that you pick.  Change 'toDoList' to the classname for your checkbox field, and 'Field18' to whichever the field number is for your checkboxes.  Here is the code, and a snapshot of before and after the code runs:

   $('#Field35-0').click(function(hideStuff){
  
         var choices = $('.toDoList input').length-1;
              
         for(i = 0; i < choices; i++) {

           if($('#Field18-' + i).is(':checked')) {
          
             $('#Field18-' + i).show('fast');
           } else {
      
             $('#Field18-' + i).parent().hide('slow');

           }
        }
         


     });

BEFORE:

 

AFTER

0 0
replied on August 2, 2016

Ok, put this on the top, just inside your document.ready function opening:

 

 if ($("#Field35-0").is(':checked')){
   var picks = $('.toDoList input').length-1;

  for(i = 0; i < picks; i++) {

           if($('#Field18-' + i).is(':checked')) {
          
             $('#Field18-' + i).show('fast');
           } else {
      
             $('#Field18-' + i).parent().hide('slow');

           }
        }
}
  

That way, it will check the trigger checkbox when the page loads, and if it is checked it will hide the unselected labels and checkboxes even for further approvals, repository saving, etc.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.