4 Replies Latest reply on Aug 12, 2008 2:48 AM by (bharathiam)

    Challenge... Deselect a "CheckAll" checkbox without impacting a previous javascript....

    Level 1
      Hello:

      I am a Newbie at JavaScript. I am currently creating a form using Adobe LiveCycle Designer 8.1.12

      On my form I have a table of 50 states each having its own checkbox assigned to it. Then I placed on the table a checkbox which I called "CheckAllStates". With the help of friends on this forum, I placed the following code to my "CheckAllStates" element so that if it was checked, all the state checkboxes would be checked and if it was unchecked then all the state checkboxes would uncheck. Below is the code that does that with a sample of the Array:

      //First create an array for the State check box names

      var stateArray = new Array("AL", "AK", "TN", "TX", "UT", "VA", "VT", "WA", "WI", "WV", "WY");

      //Then apply the code to check or uncheck the state checkboxes depending on the status
      //of the checkall checkbox

      for ( var state in stateArray )
      if (this.rawValue==1)
      {
      var oField = xfa.resolveNode("xfa.form.PROPAC_APP.PROPAC_Page2.Subform2.tblStatesUSA.Row[*].CSKK_" + stateArray[state]);
      oField.rawValue = 1;
      } else {
      var oField = xfa.resolveNode("xfa.form.PROPAC_APP.PROPAC_Page2.Subform2.tblStatesUSA.Row[*].CSKK_" + stateArray[state]);
      oField.rawValue = 0;
      }

      It works great and I thought my problem was resolved. Then I noticed that, if all states were checked, and I uncheck any of the state checkboxes individually, my "checkallstates" remains with a check. This does make sense to me, so I thought that I would simply apply the following code to each state checkboxs onclick event to uncheck my "checkallstates"

      xfa.form.PROPAC_Page2.Subform2.tblStatesUSA.Row[4].CheckALLStates.rawValue = 0;

      Unfortunately nothing happens. To test my new script, I created a new form and applied three checkboxes and applied the same concept to my checkbox called CK1:

      CK2.rawValue = "0";

      This does work, so my question is what am I doing wrong? I am thinking that my "If" and "Else" statement in my "checkallstates" onclick event is involved with this not working.

      Any ideas??

      Thanks,

      Keith.