Check All Box with on a Adobe 8.0 pdf form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kcdoell
    New Member
    • Dec 2007
    • 230

    #16
    The only way that I can get the checkbox to have a check is to click on it manually.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #17
      So you have two problems. What I suggest is try getting a checkbox checked using JavaScript first and then worry about getting it to work on clicking a button.

      Also try an alert popup to test that you can run code when a button is clicked.

      Comment

      • kcdoell
        New Member
        • Dec 2007
        • 230

        #18
        CheckBox Select All

        Hello:

        I am a Newbie at JavaScript so please be patient and kind. I am currently creating a form using Adobe LiveCycle Designer 8.0.

        On my form I have a section that displays 50 check boxes representing 50 states in the USA. On my form it is reasonable that a end user could select some or all of the states. To that end, I want to have a checkbox or button that will select and deselect all of the State checkboxes. So far I have added a button called "Select All" and on the click event I wrote the following script:

        [CODE=javascript]xfa.form.topmos tSubform.Page2. CKSS_AL.rawValu e=1
        xfa.form.topmos tSubform.Page2. CKSS_AK.rawValu e=1
        xfa.form.topmos tSubform.Page2. CKSS_AR.rawValu e=1
        xfa.form.topmos tSubform.Page2. CKSS_AZ.rawValu e=1
        xfa.form.topmos tSubform.Page2. CKSS_CA.rawValu e=1
        [/CODE]
        etc.....

        As you can see I have named my checkboxes CKSS_AL, CKSS_AK,,,etc…. .CKSS_WY.

        This works, but I am thinking that there must be a more efficient way of writing this code. So with that said I took an idea to build an array:

        [CODE=javascript]var stateArray = new Array("AL", "AK", "AR");
        for ( var state in stateArray )
        {
        var oField = xfa.resolveNode ("xfa.topmostSu bform.Page2.CKS S_" + stateArray[state]);
        oField.rawValue = 1;
        }
        [/CODE]
        I only did the array for the first 3 states/checkboxes. Then I copied it into the click event of my "SelectAll" button. I received the following error:

        oField has no properties
        5:XFA:topmostSu bform[0]:Page2[0]:SelectAll[0]:click
        oField has no properties
        5:XFA:topmostSu bform[0]:Page2[0]:SelectAll[0]:click

        Any ideas what I am missing? I have no idea what these error messages mean to solve....

        Thanks,

        Keith.
        Last edited by acoder; Feb 21 '08, 10:31 AM. Reason: Added code tags

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #19
          Originally posted by kcdoell
          Hello:

          I am a Newbie at JavaScript so please be patient and kind. I am currently creating a form using Adobe LiveCycle Designer 8.0.

          On my form I have a section that displays 50 check boxes representing 50 states in the USA. On my form it is reasonable that a end user could select some or all of the states. To that end, I want to have a checkbox or button that will select and deselect all of the State checkboxes. So far I have added a button called "Select All" and on the click event I wrote the following script:

          xfa.form.topmos tSubform.Page2. CKSS_AL.rawValu e=1
          xfa.form.topmos tSubform.Page2. CKSS_AK.rawValu e=1
          xfa.form.topmos tSubform.Page2. CKSS_AR.rawValu e=1
          xfa.form.topmos tSubform.Page2. CKSS_AZ.rawValu e=1
          xfa.form.topmos tSubform.Page2. CKSS_CA.rawValu e=1

          etc.....

          As you can see I have named my checkboxes CKSS_AL, CKSS_AK,,,etc…. .CKSS_WY.

          This works, but I am thinking that there must be a more efficient way of writing this code. So with that said I took an idea to build an array:

          var stateArray = new Array("AL", "AK", "AR");
          for ( var state in stateArray )
          {
          var oField = xfa.resolveNode ("xfa.topmostSu bform.Page2.CKS S_" + stateArray[state]);
          oField.rawValue = 1;
          }

          I only did the array for the first 3 states/checkboxes. Then I copied it into the click event of my "SelectAll" button. I received the following error:

          oField has no properties
          5:XFA:topmostSu bform[0]:Page2[0]:SelectAll[0]:click
          oField has no properties
          5:XFA:topmostSu bform[0]:Page2[0]:SelectAll[0]:click

          Any ideas what I am missing? I have no idea what these error messages mean to solve....

          Thanks,

          Keith.

          you may use this instead
          [html]<input name="all" type="checkbox" onclick="checkA ll()"></input>[/html]
          [CODE=javascript]
          function checkAll() {
          for (var i=0; i<document.form Name.elements.l ength; i++) {
          var e=document.form Name.elements[i];
          if ((e.name != 'all') && (e.type=='check box'))
          e.checked=docum ent.formName.al l.checked;
          }
          }[/CODE]

          Comment

          • kcdoell
            New Member
            • Dec 2007
            • 230

            #20
            Thanks but when I pasted the script into my click event and then went to the preview mode and click on the select all button nothing happen.

            [CODE=javascript]function checkAll() {
            for (var i=0; i<document.form Name.elements.l ength; i++) {
            var e=document.form Name.elements[i];
            if ((e.name != 'all') && (e.type=='check box'))
            e.checked=docum ent.formName.al l.checked;
            }
            }
            [/CODE]
            I know that the Adobe liveCycle designer has different JavaScript commands than previous versions. Could that be the issue?
            Last edited by acoder; Feb 21 '08, 10:32 AM. Reason: Added code tags

            Comment

            • kcdoell
              New Member
              • Dec 2007
              • 230

              #21
              Okay; to my button called "Select All" on the click event I wrote the following script:

              [CODE=javascript]xfa.form.topmos tSubform.Page2. CKSS_AL.rawValu e=1
              xfa.form.topmos tSubform.Page2. CKSS_AK.rawValu e=1
              xfa.form.topmos tSubform.Page2. CKSS_AR.rawValu e=1
              xfa.form.topmos tSubform.Page2. CKSS_AZ.rawValu e=1
              xfa.form.topmos tSubform.Page2. CKSS_CA.rawValu e=1
              [/CODE]
              etc.....

              As you can see I have named my checkboxes CKSS_AL, CKSS_AK,,,etc…. .CKSS_WY.

              This works, but as I mentioned earlier, I am thinking that there must be a more efficient way of writing this code. So with that said I took an idea to build an array:

              [CODE=javascript]var stateArray = new Array("AL", "AK", "AR");
              for ( var state in stateArray )
              {
              var oField = xfa.resolveNode ("xfa.topmostSu bform.Page2.CKS S_" + stateArray[state]);
              oField.rawValue = 1;
              }
              [/CODE]
              I only did the array for the first 3 states/checkboxes. Then I copied it into the click event of my "SelectAll" button. I received the following error:

              oField has no properties
              5:XFA:topmostSu bform[0]:Page2[0]:SelectAll[0]:click
              oField has no properties
              5:XFA:topmostSu bform[0]:Page2[0]:SelectAll[0]:click

              Any ideas what I am missing? I have no idea what these error messages mean to solve....

              Thanks,

              Keith.
              Last edited by acoder; Feb 21 '08, 10:29 AM. Reason: Added code tags

              Comment

              • kcdoell
                New Member
                • Dec 2007
                • 230

                #22
                Got some help and finally got this one solved:

                [CODE=javascript]var stateArray = new Array("AL", "AK", "AR");
                for ( var state in stateArray )
                {
                var oField = xfa.resolveNode ("xfa.form.topm ostSubform.Page 2.CKSS_" + stateArray[state]);
                oField.rawValue = 1;
                }
                [/CODE]
                Keith.
                Last edited by acoder; Feb 21 '08, 10:30 AM. Reason: Added code tags

                Comment

                • kcdoell
                  New Member
                  • Dec 2007
                  • 230

                  #23
                  Got some help from another friend and finally got this one solved:

                  [CODE=javascript]var stateArray = new Array("AL", "AK", "AR");
                  for ( var state in stateArray )
                  {
                  var oField = xfa.resolveNode ("xfa.form.topm ostSubform.Page 2.CKSS_" + stateArray[state]);
                  oField.rawValue = 1;
                  }
                  [/CODE]
                  Keith.
                  Last edited by acoder; Feb 21 '08, 10:33 AM. Reason: Added code tags

                  Comment

                  • hsriat
                    Recognized Expert Top Contributor
                    • Jan 2008
                    • 1653

                    #24
                    Originally posted by kcdoell
                    Got some help from another friend and finally got this one solved:

                    var stateArray = new Array("AL", "AK", "AR");
                    for ( var state in stateArray )
                    {
                    var oField = xfa.resolveNode ("xfa.form.topm ostSubform.Page 2.CKSS_" + stateArray[state]);
                    oField.rawValue = 1;
                    }

                    Keith.
                    Buddy, you got to change the document and formName to the ones used by you.
                    I dunno about Adobe thing, I never used it.

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #25
                      As a full member now, you should know that we expect your code to be posted in [CODE] tags (See How to Ask a Question).

                      This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

                      Please use the tags in future.

                      MODERATOR.

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #26
                        Originally posted by kcdoell
                        Got some help and finally got this one solved:
                        Maybe I'm missing something, but how is this different from what you posted before?

                        PS. merged duplicate threads.

                        Comment

                        • kcdoell
                          New Member
                          • Dec 2007
                          • 230

                          #27
                          Originally posted by acoder
                          Maybe I'm missing something, but how is this different from what you posted before?

                          PS. merged duplicate threads.
                          Acoder:

                          My JavaScript before was the following:

                          [code=javascript]
                          var stateArray = new Array("AL", "AK", "AR");
                          for ( var state in stateArray )
                          {
                          var oField = xfa.resolveNode ("xfa.topmostSu bform.Page2.CKS S_" + stateArray[state]);
                          oField.rawValue = 1;
                          }
                          [/code]

                          all that was missing was a the word "form."

                          The end solutions was the following:

                          [code=javascript]
                          var stateArray = new Array("AL", "AK", "AR");
                          for ( var state in stateArray )
                          {
                          var oField = xfa.resolveNode ("xfa.form.topm ostSubform.Page 2.CKSS_" + stateArray[state]);
                          oField.rawValue = 1;
                          }
                          [/code]

                          Take care,

                          Like I had mentioned before, my knowledge on Javascript is limited but it appears that the problem was path related.

                          Keith.

                          Comment

                          • acoder
                            Recognized Expert MVP
                            • Nov 2006
                            • 16032

                            #28
                            Originally posted by kcdoell
                            all that was missing was a the word "form."
                            Oh right, so it was. Thanks for posting and glad you got it working.

                            JavaScript on Adobe PDF can be difficult if you're used to the normal standard JavaScript.

                            Comment

                            Working...