Skip navigation
Currently Being Moderated

LockAllFields Script Help

May 27, 2010 6:00 AM

Hi All,

 

Having some trouble with a LockAllFields script.

 

I'm trying to make a button which will lock all the fields on a form. I've been using the following script:

 

myScriptObject.LockAllFields(form1);

 

This is set to run on mouse up.

 

I've created a script object in the root (form1) and just called it myScriptObject

 

Do I need to do anything else with the object at all?

 

At the moment I'm getting the an error when I press the lock button in Reader (see attached)error.jpg

 

 

What do I need to do to get this working?

 

Many Thanks!

 
Replies
  • Currently Being Moderated
    May 27, 2010 6:20 AM   in reply to chrishillarc

    Try this script..

     

    xfa.form.form1.access = "readOnly";

     

    Thanks

    Srini

     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2010 6:20 AM   in reply to chrishillarc

    Hi ,

     

    You can set the access of the fields "readonly" while clicking the button . You can use it either in mouseup or in click event .There must be a parent subform . So you can use the following script . I am not sure but I guess it will be of some worth.

     

    rootsubform.access = "readOnly";

     

    Hope it helps.

     

    Thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2010 7:16 AM   in reply to chrishillarc

    Here is your corrected form..Check the Click event of the Button. I placed the controls on a body page..

    https://acrobat.com/#d=CbKINJFsCkZvgvQatNLBKQ

     

    Few observations..

    1) You have used "myScriptObject" in your code but actually you did put a name for your script object. You can check it in Heirarchy..

    2) You placed all the controls on the Master Page and the access property was not available for the Master page.

     

     

    Thanks

    Srini

     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2010 8:48 AM   in reply to chrishillarc

    In the form I sent you earlier, follow these steps..

     

    1) goto the Click event of the button and Change the language to "Java Script"

    2) Remove all the code in the click event and place the below line..

         myScriptObject.LockAllFields(form1);  

    3) Save the form as Dynamic XML Form instead of Static.

     

    Here is the updated form..

    https://acrobat.com/#d=PDEhdSHGdss-qMJer*BHuw

     

     

    Let me know if you still have issues..

     

    Thanks

    Srini

             

     

     
    |
    Mark as:
  • Currently Being Moderated
    May 27, 2010 9:53 AM   in reply to chrishillarc

    That is probably because the script was locking all the fields on the form including the signature field.

     

    Why don't you try moving the code from the click event of the button to postSign event of the Signature Field..That can help..

     

    Thanks

    Srini

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2010 5:18 AM   in reply to chrishillarc

    You have to Reader Extend the form to allow signatures to be used in Reader. Also the sig field must already exist before Reader opens it. You can Reader Extend in Acrobat to allow this.

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2010 6:37 AM   in reply to chrishillarc

    You canadd a signature field in Designer (this is just a place holder). It becomes a real signature when the disgner makes the pdf.

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2010 5:22 AM   in reply to chrishillarc

    Do you mean using a signature pad to apply the signature to the field?

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2010 6:01 AM   in reply to chrishillarc

    So if you do not lock the fields ....will it sign for you?

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2010 6:30 AM   in reply to chrishillarc

    So when you say draw all over it you are not simply drawing on the signature field? Are you using a tool on the commenting toolbar to do the drawing?

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2010 7:16 AM   in reply to chrishillarc

    Ok I think I have figured this out. The lock all fields is a red herring. That option you are using is simply adding a comment to the form. Comments cannot be added to a dynamic form. If you save your form as a static PDF then that technique will work whether the fields are locked or not.

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 4, 2010 8:49 AM   in reply to chrishillarc

    Yes ...simply use this command after the call to the lock fields script

     

    TextFieldName.presence = "invisible"

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 8, 2010 5:27 AM   in reply to chrishillarc

    That is right ....make sure you save the form as dynamic. Also if it still does not work then hit the ctrl-j during preview and if you are using Acrobat the Javascript console will come up and report any scripting errors.

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 8, 2010 5:58 AM   in reply to chrishillarc

    Sorry ...answering so many questions I get the issues mixed up. Your code looks fine ...can you email the form to LiveCycle8@gmail.com so I can have a look?

     

    Paul

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 12, 2011 1:40 PM   in reply to chrishillarc

    Hello Paul, Hope you are in good spirits today..

     

    I have a simple question I believe. (hopefully)

     

    I am using your lock all fields script and it works great, however I would like to omit a single email submission button from this script. Can you explain how I would do that. This is a very basic, single page form.

     

    The other option would be to add some code to the lock all fields button so it would mailto: after the form was locked.

     

    Sorry if this has already been answered, I looked through the thread and didn't see anything about it.

     


    Thanks so much!

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 16, 2011 5:20 AM   in reply to CoreyScheck

    No probs ....

     

    In the function that locks all fields each object on the form is identified and checked for its clsssname  - if it is a field then we know that is one of the following (DDList, TextField, NumericField, radio button, checkbox , Button , etc...). We can do a subsequent check to see if it is a button. In my case a named all of my buttons Button1, Button2 etc... so I simply choose each object with a classname of field and a name that has Button for its first 6 chars and I omit that from the lock procedure. I included a modified sample to give you the idea as well here is the modified script object  that I used:

     

    /********************************************************************* ****************
    Function: LockAllFields
    Description: This function will lock all fields.
    IN: The parent subform. It could also be an element that contains subform like form1
    OUT : nothing
    ********************************************************************** ****************/
    function LockAllFields(myParentObject){

    var allChildElements;
    var intNumElements;
    var currentElement;
    var j;
    var temp;

    //Get all the child nodes of the parent element
    allChildElements = myParentObject.nodes;

    //Total number of element in the object
    intNumElements = allChildElements.length;

    //Loop through all the child elements
    for(j=0; j< intNumElements;j++){
      currentElement = allChildElements.item(j);
      //If the element is another subform we'll recusively call the function again
      if(allChildElements.item(j).className == "subform"){
       LockAllFields(currentElement);
      }
      //If the objects are fields and they are set to mandatory (validate.nullTest) then we will set the border.fill.color - dependant on object type
      else if(currentElement.className == "field"){
       //CHeck to see if the field is a button - do not lock buttons
       temp =  currentElement.name;
       if (temp.substring(0,6) != "Button"){
        currentElement.access = "readOnly";
       }
      
      }
       //Check for exclusion groups - Radio Buttons
       else if(currentElement.className == "exclGroup"){
       for(k=0; k< currentElement.nodes.length;k++){
        if(currentElement.nodes.item(k).className == "field"){
         //set the color for the radio buttons individually
         currentElement.access = "readOnly";
        }
      
       }
      }
    }
    }//end function

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points