2 Replies Latest reply on Jul 1, 2013 8:04 AM by rhyswill

    Checkbox help

    rhyswill

      HI,

       

      I currently using javascript within a PDF to make a form simpler to use. I have a checkbox list with a sub-checkbox list within it (see below)

      list.jpg

       

      When filling in the form I need the user to only be able to check one item for the primary list and then a further item if the chekc the box with the sublist.

       

      I have been able to achieve this using the following document level code and the mouse up - run javascript option.

       

      function cbControl()
      {

          var f1 = getField("Eligible activity 1"); (Area benefit checkbox above)
          var f2 = getField("Eligible activity 2"); (limited Clientle checkbox)
          var f3 = getField("Eligible activity 3"); (Housing checkbox above)
          var f4 = getField("Eligible activity 4"); (Jobs checkbox above)
          var f5 = getField("LCB sublist 1"); (Project activity maintains client records checkbox above)
          var f6 = getField("LCB sublist 2"); (Project activity has income eligiblity checkbox above)
          var f7 = getField("LCB sublist 3"); (Project activity is of such a nautre checkbox above)
          var f8 = getField("LCB sublist 4"); (Project activity clients are presumed checkbox above)
         
          if (event.target === f1) {
              f2.value = "Off";
              f3.value = "Off";
              f4.value = "Off";
              f5.value = "Off";
              f6.value = "Off";
              f7.value = "Off";
              f8.value = "Off";
              return;
          } 

          if (event.target === f2) {
              f1.value = "Off";
              f3.value = "Off";
              f4.value = "Off";
              return;
          }

          if (event.target === f3) {
              f1.value = "Off";
              f2.value = "Off";
              f4.value = "Off";
              f5.value = "Off";
              f6.value = "Off";
              f7.value = "Off";
              f8.value = "Off";
              return;
          }   

          if (event.target === f4) {
              f1.value = "Off";
              f2.value = "Off";
              f3.value = "Off";
              f5.value = "Off";
              f6.value = "Off";
              f7.value = "Off";
              f8.value = "Off";
              return;
          } 

       

      function sublistControl()
      {

          var f1 = getField("Eligible activity 1");
          var f2 = getField("Eligible activity 2");
          var f3 = getField("Eligible activity 3");
          var f4 = getField("Eligible activity 4");
          var f5 = getField("LCB sublist 1");
          var f6 = getField("LCB sublist 2");
          var f7 = getField("LCB sublist 3");
          var f8 = getField("LCB sublist 4");
         
          if (event.target === f5) {
              f1.value = "Off";
              f3.value = "Off";
              f4.value = "Off";
              f6.value = "Off";
              f7.value = "Off";
              f8.value = "Off";
              return;
          } 

          if (event.target === f6) {
              f1.value = "Off";
              f3.value = "Off";
              f4.value = "Off";
              f5.value = "Off";
              f7.value = "Off";
              f8.value = "Off";
              return;
          } 

          if (event.target === f7) {
              f1.value = "Off";
              f3.value = "Off";
              f4.value = "Off";
              f5.value = "Off";
              f6.value = "Off";
              f8.value = "Off";
              return;
          } 

          if (event.target === f8) {
              f1.value = "Off";
              f3.value = "Off";
              f4.value = "Off";
              f5.value = "Off";
              f6.value = "Off";
              f7.value = "Off";
              return;
          } 
      }

       

      However no matter what I try, I can not get the 'Eligible activity 2' box to check if some one selects one of the sublists checkboxes. I have tried including the follwoing into the sublistControl code

       

      if (event.target === f5) {

              f1.value = "Off";

              f2.value = "On"; (also tried f2.value = "Yes";)

              f3.value = "Off";

              f4.value = "Off";

              f6.value = "Off";

              f7.value = "Off";

              f8.value = "Off";

              return;

       

      But this does not work. Can anybody suggest a solution??

       

      Kind regards

       

      Rhys