Professional Web Applications Themes

Custom Value in Field Name HOW TO? - Adobe Acrobat Windows

In other developer tools, I can determine what fields should print or be displayed based on conditions. For instance in the case of an address such as below: Line 1: NAME Line 2: ADDRESS LINE1 Line 3: ADDRESS LINE2 Line 4: CITY, STATE ZIP I would print the city, state and zip on the third line if there is no value in the field for address line2 using something similar to: IIF(EMPTY(ag_addr2),ALLTRIM(ag_city)+", "+ag_state+" "+IIF(LEN(ALLTRIM(ag_zip)) > 5,TRANS(ag_zip,"rz 99999-9999"),ag_zip),ag_addr2) for the 3rd line in the address (address line2). Is there any way to specify a condition for field names? If this must ...

  1. #1

    Default Custom Value in Field Name HOW TO?

    In other developer tools, I can determine what fields should print or be displayed based on conditions. For instance in the case of an address such as below:

    Line 1: NAME
    Line 2: ADDRESS LINE1
    Line 3: ADDRESS LINE2
    Line 4: CITY, STATE ZIP

    I would print the city, state and zip on the third line if there is no value in the field for address line2 using something similar to:

    IIF(EMPTY(ag_addr2),ALLTRIM(ag_city)+", "+ag_state+" "+IIF(LEN(ALLTRIM(ag_zip)) > 5,TRANS(ag_zip,"rz 99999-9999"),ag_zip),ag_addr2)

    for the 3rd line in the address (address line2). Is there any way to specify a condition for field names? If this must be done using a java script, is there an example of something similar to look at somewhere?

    TIA,
    Tracy
    tracycholzer@adobeforums.com Guest

  2. #2

    Default Re: Custom Value in Field Name HOW TO?

    I guess no one has any ideas? I was hoping someone else had run into this already...
    tracycholzer@adobeforums.com Guest

  3. #3

    Default Re: Custom Value in Field Name HOW TO?

    One solution would be to create a text field built using all the values from the individual fields.

    var conC ="";
    var L = this.getField('label');

    //create a string array with all the field values
    //adding new line when appropriate

    var fA = new Array();
    fA[fA.length]= this.getField('name').value+'\r';
    fA[fA.length]= this.getField('addr1').value+'\r';
    fA[fA.length]= this.getField('addr2').value+'\r';
    fA[fA.length]= this.getField('city').value+", "+this.getField('state').value+" "+this.getField('zip').value;

    //loop through the array testing for values
    //containing more than 1 character

    for(var i in fA){
    if(fA[i].length>1){
    conC+=fA[i]
    }
    }

    //set the field value to equal the resulting string array
    L.value = conC

    caution: this code has not been tested and may require changes !
    Ben_Marchbanks@adobeforums.com Guest

  4. #4

    Default Re: Custom Value in Field Name HOW TO?

    Thanks for the idea Ben. I would like to test it. Where would this code be placed since it references more than one field on the form? Is there a location for scripts like this that are run when the form is instantiated or would it only run when the sngle field is instantiated? If the latter, where the code be placed?
    tracycholzer@adobeforums.com Guest

  5. #5

    Default Re: Custom Value in Field Name HOW TO?

    You might use this as a custom calculation script for the "label" field - under field properties but I rather use events to trigger the script based on the user process.

    If you are viewing one "record" at a time the JavaScript could run at the doent level following some type of event as a trigger. "Page open" for example or following submittal/retrieval of a "record"
    Ben_Marchbanks@adobeforums.com Guest

  6. #6

    Default Re: Custom Value in Field Name HOW TO?

    A question on your code:

    var L = this.getField('label');

    Does 'this.' refer to the form or the field? Based on other languages, I would assume the form since in your example the field 'label' would be a property of the form, correct?

    So if the actual field name was AGENCY.NAME I would use:

    var L = This.GetField('AGENCY.NAME')

    right? And from then on L would be an object pointing to the field AGENCY.NAME?
    tracycholzer@adobeforums.com Guest

  7. #7

    Default Re: Custom Value in Field Name HOW TO?

    yes - but remember JS is case sensitive this.getField() is not the same as This.GetField()
    Ben_Marchbanks@adobeforums.com Guest

  8. #8

    Default Re: Custom Value in Field Name HOW TO?

    That makes sense. I would want it to run when the form is opened and not again after that. The user is allowed to edit the field values but I need to put default values in them first based on data in the .xfdf file. Speaking of which (well actually writing of which), since I am using an .xfdf file to populate the fields on the form, will the values from the .xfdf file be readin FIRST and then then special code I enter (in the field calculation or the form's page open event etc) run afterwards? Is there any doentation that lists the order of events firing?
    tracycholzer@adobeforums.com Guest

  9. #9

    Default Re: Custom Value in Field Name HOW TO?

    Actually, one of the best resources is the Acrobat JavaScript Scripting Reference which includes a model of the Event Object.

    This doent used to be included with Acrobat prior to version 6 but now must be downloaded from Adobe

    <http://partners.adobe.com/asn/acrobat/docs.jsp>
    Ben_Marchbanks@adobeforums.com Guest

  10. #10

    Default Re: Custom Value in Field Name HOW TO?

    Thanks Ben,

    You've been a great help. I must admit that I am quite surprised at how little doentation is available to developers or even users of Adobe Acrobat 6 Professional version without an additional annual 195.00 basic membership. I would think all that developer doentation would be included when you purchase the Professional version. It is with other developer tools.
    tracycholzer@adobeforums.com Guest

  11. #11

    Default Re: Custom Value in Field Name HOW TO?

    I agree - not including the JS Reference with Professional does not make sense.
    Ben_Marchbanks@adobeforums.com Guest

  12. #12

    Default Re: Custom Value in Field Name HOW TO?

    Which JavaScript doentation requires a membership?

    Aandi Inston
    Aandi_Inston@adobeforums.com Guest

  13. #13

    Default Re: Custom Value in Field Name HOW TO?

    <https://partners.adobe.com/asn/acrobat/sdk/reqdeveula.jsp?accessNextURL=/asn/acrobat/sdk/explodedSDK/Doentation/JavaScript/VBJavaScript.pdf>

    <https://partners.adobe.com/asn/acrobat/sdk/reqdeveula.jsp?accessNextURL=/asn/acrobat/sdk/explodedSDK/Doentation/JavaScript/AcroJS-MM.pdf>

    <https://partners.adobe.com/asn/acrobat/sdk/reqdeveula.jsp?accessNextURL=/asn/acrobat/sdk/explodedSDK/Doentation/Getting_Started/DevelopmentOverview.pdf>
    tracycholzer@adobeforums.com Guest

Similar Threads

  1. conditional required cfform field + custom javascriptvalidation
    By rockasocki in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: July 18th, 08:43 PM
  2. custom field in verity
    By davidihill in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: May 14th, 12:13 AM
  3. Web Custom Control error on ID field
    By Steve Mauldin in forum ASP.NET Building Controls
    Replies: 1
    Last Post: July 28th, 11:36 PM
  4. Allow custom text in a calculated field when a zero value is present
    By Ken_Stockford@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 9
    Last Post: May 14th, 01:10 PM
  5. Custom Stamp with Text Field?
    By Laurel Chauvin in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: April 16th, 08:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139