11 Replies Latest reply on Jun 6, 2014 9:52 AM by PleaseHelpMe

    Turn off read only when radio button is selected?

    PleaseHelpMe

      I have two radio buttons to hide/show the second page in an Acrobat Form. All fields on the second page are marked read only. The second page is hidden by a text box with the background and border turned white. The No button is auto-selected so that that the second page appears blank. When the Yes button is selected, the text box hiding the second page goes away. I need the fields on the second page to be fillable when the Yes button is selected. The second page has about 124 fields that need to have read only turned off when the Yes button is selected. I am not sure if I have missed something in my script or not and I'm kind of cross-eyed at this point. Here is part of the script. I took a bunch out because it's so long. Is there a length limit to how much should be on one action or am I making a mistake on how I've written this?

       

      //on Mouse Up run javascript

       

      if(this.getField(event.target.name).value == "Yes"){

       

          this.getField("pg2.Unit #").readOnly = false;

          this.getField("pg2.MFG").readOnly = false;

          this.getField("pg2.Model").readOnly = false;

         

          this.getField("pg2.Serial").readOnly = false;

          this.getField("pg2.Voltage").readOnly = false;

          this.getField("pg2.Phase").readOnly = false;

         

          this.getField("pg2.Cycle").readOnly = false;

          this.getField("pg2.Text5").readOnly = false;

          this.getField("pg2.Text6").readOnly = false;

         

          this.getField("pg2.Text7").readOnly = false;

          this.getField("pg2.Text8").readOnly = false;

          this.getField("pg2.Text9").readOnly = false;

       

          this.getField("pg2.Part4").readOnly = false;

          this.getField("pg2.Description4").readOnly = false;

          this.getField("pg2.Vendor4").readOnly = false;

       

          this.getField("pg2.Part7").readOnly = false;

          this.getField("pg2.Description7").readOnly = false;

          this.getField("pg2.Vendor7").readOnly = false;

         

          this.getField("pg2.M Volt2").readOnly = false;

          this.getField("pg2.M Phase2").readOnly = false;

          this.getField("pg2.M Amps2").readOnly = false;

         

          this.getField("pg2.Additional RemarksRow1").readOnly = false;

          this.getField("pg2.Dropdown2").readOnly = false;

      }

        • 1. Re: Turn off read only when radio button is selected?
          try67 MVP & Adobe Community Professional

          The name of the property is readonly, not readOnly... JS is case-sensitive,

          remember.

          • 2. Re: Turn off read only when radio button is selected?
            PleaseHelpMe Level 1

            Thank you, Gilad. I always appreciate your help.

             

            I had originally had all lower case readonly but had changed it to readOnly to see if that was my problem. It was not, obviously. I have changed it back to readonly now, with no change in results.

             

            I also tried moving the { that was on the first line to be down on it's own. I also tried changing my indention from 4 spaces to 3 spaces. None of those solutions worked.

             

            One question I have -- if the field name is "Junction Box", would I say this.getField("pg2.Junction Box") or this.getField("pg2.Junction_Box") -- I was unclear on that. The example I am using to learn from has underscores between the words of the field names.

             

            I need to be able to turn off the read only on each field when the button is pressed. Any ideas?

            • 3. Re: Turn off read only when radio button is selected?
              try67 MVP & Adobe Community Professional

              If the field's name is "Junction Box", access it with this.getField("Junction Box") ... Don't add or replace anything!

              • 4. Re: Turn off read only when radio button is selected?
                PleaseHelpMe Level 1

                Update:

                 

                Sorry for the overdue reply. This project is, unfortunately, not on the front burner. I have been able to get the desired effect on a small scale with one field working properly! I will begin fleshing out the rest of it this afternoon and hopefully it stays consistent in all 124 fields on page 2.

                 

                I have another question though. Is there a difference in effectiveness when utilizing the Action function? For instance:

                 

                I have a set of radio buttons. "Yes/No1"

                The "No" button is selected by default. The "No" button is Read Only by default. There is a Mouse Up Action to show/hide a field that covers the second page (Action #1), and a Mouse Up Action to set field(s) Read Only to true when pressed (Action #2).

                The "Yes" button's Mouse Up Actions are to hide a field that covers the second page (Action #1), a Mouse Up Action to Run a Javascript that copies information from certain fields on page 1 to page 2 (Action #2), and a Mouse Up Action to set field(s) Read Only to false when pressed (Action #3).

                 

                Capture2.PNG

                 

                So, my question is (since I can't seem to find the right words to ask on Google), should I be combining all of these into one Mouse Up Action or does it matter? Does it slow the speed of the function down if I am asking it to do multiple Mouse Up Actions (versus one long JS) at once or can I leave it like this? I prefer it like this because I'm just learning and once I get a piece of the puzzle that I know works, I like to keep it separate.

                 

                Any thoughts would be appreciated.

                 

                And, thank you, Gilad. I appreciate your guidance.

                • 5. Re: Turn off read only when radio button is selected?
                  try67 MVP & Adobe Community Professional

                  I would do it all in a single JS action. If that action is then general enough you can even place it in a function at the doc-level script and just call it from the fields. That way, your actual code is located in a single location and it would be much easier to edit it later on.

                  • 6. Re: Turn off read only when radio button is selected?
                    PleaseHelpMe Level 1

                    Gilad, a million "thank you"s.

                     

                    Speaking of doc-level script. I am looking into putting in a doc-level script that says if a field is selected then page 2 does not print. Unfortunately, I am working with Acrobat Standard XI, instead of Acrobat Pro XI, so I do not have the Action Wizard.

                     

                    My next questions are...

                     

                    1.) Is there going to be any kind of compatibility issue with using a doc-level script and my group using only Acrobat Reader?

                     

                    2.) Is a doc-level script in this context possible using Acrobat Standard? I have been playing with "Set Document Actions" but it seems to be fairly useless.

                    • 7. Re: Turn off read only when radio button is selected?
                      try67 MVP & Adobe Community Professional

                      There's no way to set a page as "non printable"... You can hide its contents in multiple ways, but you can't prevent it from being printed.

                      • 8. Re: Turn off read only when radio button is selected?
                        PleaseHelpMe Level 1

                        Well, I tried first to put a little script on the "No" button that said not to print it if the "No" button was clicked. That worked ok, except it brought the print screen up immediately instead of waiting for the user to ask the program to print the document. I only want my end user to think about printing the form so I don't want my middle-users to have to see the print screen.

                         

                        if(this.getField(event.target.value) == "No"){

                        print({nStart : 0, nEnd : 0});}

                         

                        Then, I tried to to put a script in one of the other text fields so that I could format it to not print the second page if the value of the radio button was "No". This worked the way I wanted it to (it chose to print only page 1 of 1 when I had the "No" button selected and clicked the Print button) but crashes my Acrobat every time I enter anything into the form after I click the "No" button, so I took it out.

                         

                        if(this.getField("Yes/No1").value == "No"){

                        print({nStart : 0, nEnd : 0});}

                         

                        I tried to do the same type of script on the document level with "willPrint" but that didn't work at all, which arguably could just be that I need to tweak the script until it works.

                         

                        But, I think I understand what you mean -- I can tell it what TO print instead of saying what NOT to print. Sorry. Took a minute to process.

                        • 9. Re: Turn off read only when radio button is selected?
                          try67 MVP & Adobe Community Professional

                          I don't think you quite understood me... You can open the Print dialog for the user and specify the page numbers, but they will be able to change it or open it themselves and specify their own page range. You just can't prevent a page from being printed, if the user wants to do that.

                          • 10. Re: Turn off read only when radio button is selected?
                            PleaseHelpMe Level 1

                            Ah, thank you for the clarification.

                             

                            It's ok for the end user to CHOOSE to print all of the pages they want. My concern is that I don't want that second page to print every time they open the file and hit print.


                            In the end, this form will be a total of six pages. One original page will always have content on it and will always need to be printed. Five pages will appear blank because all of the information on them is hidden unless they are selected for adding additional information. It would be annoying for the end user to have to put a bunch of blank pages back in their printers if the first page is the only one that was actually needed, especially if they had several to print out at a time.

                            • 11. Re: Turn off read only when radio button is selected?
                              PleaseHelpMe Level 1

                              Adobe Acrobat XI Standard

                              Fillable Form

                              Radio Button Value

                              Choose Pages To Print From Variable

                              Print Button

                               

                              Just in case anyone else needs to know how to make form print only a certain range of pages dependent on a set of radio button values:

                               

                              Make a button

                              On Action Mouse Up

                              Run a javascript

                               

                              if(this.getField('Yes/No1').value == 'Yes'){

                              print({

                              bUI : true,

                              nStart : 0, nEnd : 1});

                              } else {

                              if(this.getField('Yes/No1').value == 'No'){

                              print({

                              bUI : true,

                              nStart : 0, nEnd : 0});

                              }

                              }

                               

                              If the print button is clicked and the answer is Yes, the print dialog box comes up with pages 1 and 2 of the form to print. If the print button is clicked and the answer is No, the print dialog box comes up with page 1 of the form to print.

                               

                              It was hard to find the pieces to put together so I thought I would put it on here so anyone else searching for it in the future could find it.