5 Replies Latest reply on Jun 15, 2011 9:53 AM by swarren5

    Need assistance with tweaking a JavaScript for a form...

    swarren5

      In the script below, designed to lock all fields of a form; I need to tweak it so that if a specific option (Enterprise), is chosen from a DropDownList, every field in the form except TextField16 is automatically locked for editing, along with the Button functions that are already coded as exceptions in this script.  I am not a programmer, and the kind assistance from a member of this forum who gave me this script, will not be available for the next 6 weeks while he is on vacation.

       

      Anyone?

      __________________________________________________________________________________________ ________________________________________

       

      form1.#variables[0].myScriptObject - (JavaScript, client)

       

       

       

      /*************************************************************************************

      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