3 Replies Latest reply on Nov 18, 2013 10:36 AM by gkaiseril

    Please help with checkbox script

    Acp2621

      I need help.

       

      I've created a form for the first time yesterday. It's body has 14 rows and 10 columns. Some of the fields on each row are totaled in a subtotal column on each row. I was able to do that part. There's also a checkbox on each row and two additional fields at the bottom. What I need is for the sub totals on each row to be grand totaled in one of those two separate fields at the bottom with the checkbox being the factor that determines which one. Essentially, if the box is checked, that rows total is only counted in one field, and if it's unchecked, it is only counted in the other field. The combined total of the two fields should equal the grand total of the sub-total column.

       

      As I mentioned, this is my first attempt and therefore I'm very new with JavaScript. I lucked up and found someone else's script that allowed me to add/subtract across the rows and leave the sub-total blank if it's zero. The limit of my contribution was plugging in field names. So, I will literally have to copy and paste your script only changing the names.

       

      Thank you for any assistance you can provide.

        • 1. Re: Please help with checkbox script
          Acp2621 Level 1

          One way I thought of, not sure if it's possible though, is to create two hidden fields for each row, lined up into two columns (labeled in my head as "checked" and "unchecked". If the box was checked, the subtotal for that row would be copied into the "checked" hidden column, and if unchecked, it would end up in the unchecked column. This would essentially presort the subtotals, so that the two fields at the bottom would merely have to add up their respective columns.

           

          I'm not sure if this is possible, and it certainly isn't as elegant, but I believe the scripting would be much simpler.

          • 2. Re: Please help with checkbox script
            Acp2621 Level 1

            Ok,

             

            I've been working on it and am closer I believe.

             

            I'm going the route with two hidden columns. In one column, it will copy over the subtotals that are checked. In the other, the sub-totals that are unchecked. The boxes at the bottom will merely total the two columns. I have developed the following script, but can't get it to work (The subtotal field is named "Actual Length in Str feet mRow1" and the hidden field is "Text1").

             

            If (Check Box1.value == "1")

            {

            Text1.value = this.getField("Actual Length in Str feet mRow1").value;

            }

            else

            {

            Text1.value=0;

            }

             

            If I could get this to work, I could modify it dependent of which column I was working in. What are the values of a checked and unchecked check box?

            • 3. Re: Please help with checkbox script
              gkaiseril MVP & Adobe Community Professional

              Unchecked check boxes and radio buttons have a value of "Off". When a specific field  is selected, then the value is the value in "Export Value" for check boxes and "Button Value" for radio buttons.