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

Question

Question

Increment / Decrement Number Field When Checkbox is Checked / Unchecked

asked on August 17, 2017

I need to increment the "# of Citations" number field by 1 when the CITATION checkbox is checked and decrement by 1 if the same checkbox is unchecked.

The CITATION checkbox is part of a collection.

I tried to do this under ADVANCED > CALCULATION, but it wouldn't work.  As soon as I drilled down to select the CITATION variable using the caret, the red squiggle showed up underneath the variable:

The default value of the "# of Citations" field is set to 0.

CITATION checkbox value is "citation".

I appreciate any suggestions!  Thanks!

0 0

Replies

replied on August 17, 2017

Hi Laura,

That's definitely possible with Javascript:

With inspiration taken from Alex in this post and a bit of changes to account for the collection field, I got the number of checks counted properly with the following code:

$(document).ready(function () {
  $('.checkboxsum input').attr('readonly', true);
    
    $('.cboxtotal').on('change', function () {
    var sum = 0
    
    $ ('.checkbox input:checked').each(function(){
      sum +=1;
    });
    $('.checkboxsum input').val(sum);
    $('.checkboxsum input').trigger('change');
  });
  
});

CSS classes to assign:

- Collection Field: "cboxtotal"

- Checkbox Field: "checkbox"

- Checkbox Sum: "checkboxsum"

Let me know if this doesn't work.

0 0
replied on October 10, 2017

is this possible in the built in formulas in the advanced options? not javascript?

0 0
replied on August 21, 2017

Tri, thanks so much for your help!  I'm feeling a little excited because this is the first time a Laserfiche staffer has replied to one of my questions!  laugh

I don't need a sum of all checkboxes checked in all collections.  The "# of Citations" field is unique to the collection group in which it resides and it should only increment if the CITATION checkbox is checked...but not if any other checkbox is checked.

I'm trying to simulate the functionality of a collection within a collection by utilizing field rules...as suggested in this post.  However, instead of requiring the user to select a number of citations from a list, I want the form to detect the number based on whether the CITATION checkbox is checked.

There could only ever be one citation per collection group per form submittal.

For example, if the citation box is not checked:

If the citation box is checked:

Once a form with a checked CITATION checkbox is submitted, I will use Workflow's "Invoke Business Process" task to push the value of the "# of Citations" field to a new form that looks exactly the same.

If the user checks the CITATION checkbox on the new form, the value of the "# of Citations" field will increase from "1" to "2", and the form will use field rules to display input fields that will house information about Citation #2:

...and so on.

Also, if a user checks the CITATION checkbox and then changes their mind and un-checks it, I need the "# of Citations" field to revert back to whatever it's initial form value was...so that the appropriate number of Citation info fields will be displayed.

I hope you can help me!  I just can't figure out the script.

Thanks, again!

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

Sign in to reply to this post.