Adobe Java Script Expressions

Question #1    I have a check box field and two data fields containing only letters no numbers in an Adobe Acrobat Form. I would like to have a java script expression that if the Check box 1 field is checked, the contents of Data Field 1 will be automatically entered into Data Field 2 .
Please provide script and below are the 3 fields.
Check box 1 field: Checked
Data Field 1
Data Field 2
Question #2    I have a field labeled Full Address that I am trying to get the following fields to populate from. The problem in my expression is when there is no Suite then there is an extra comma still showing.
Please provide script.
Sample of my script below.
event.value = this.getField("Merchant_Addr1").value.concat( ", ", this.getField("Merchant_Addr2").value) + ", " + this.getField("Merchant_City").value + ", " + this.getField("Merchant_State").value + "  " + this.getField(" Merchant_Zip").value;
This is what displays if no Suite is in Address (Two commas after the word Drive: 23175 La King Drive, , Irvine, CA  92656
Data Field Street Address
Data Field Suite (If empty then don't show comma)
Data Field City
Data Field State
Data Field Zip

For question number 2, I would use a reusable document level function to combine 3 fields a time and adjust for null field values.
// Concatenate 3 strings with separators where needed
function fillin(s1, s2, s3, sep) {
Purpose: concatenate up to 3 strings with an optional separator
inputs:
s1: required input string text or empty string
s2: required input string text or empty string
s3: required input string text or empty string
sep: optional separator sting
returns:
sResult concatenated string
// variable to determine how to concatenate the strings
  var test = 0; // all strings null
  var sResult; // re slut string to return
// force any number string to a character string for input variables
  s1 = s1.toString();
  s2 = s2.toString();
  s3 = s3.toString();
  if(sep.toString() == undefined) sep = ''; // if sep is undefined force to null
assign a binary value for each string present 
so the computed value of the strings will indicate which strings are present
when converted to a binary value
  if (s1 != "") test += 1; // string 1 present add binary value: 001
  if (s2 != "") test += 2; // string 2 present add binary value: 010
  if (s3 != "") test += 4; // string 3 present add binary value: 100
  /* return appropriate string combination based on
  calculated test value as a binary value
  switch (test.toString(2)) {
  case "0": // no non-empty strings passed - binary 0
     sResult = "";
  break;
  case "1": // only string 1 present - binary 1
     sResult = s1;  
  break;
  case "10": // only string 2 present - binary 10
     sResult = s2;  
  break;
  case "11": // string 1 and 2 present - binary 10 + 1
     sResult = s1 + sep + s2; 
  break;
  case "100": // only string 3 present - binary 100
     sResult = s3;
  break;
  case "101": // string 1 and 3 - binary 100 + 001
     sResult = s1 + sep + s3; 
  break;
  case "110": // string 2 and 3 - binary 100 + 010
     sResult = s2 + sep + s3; 
  break;
  case "111": // all 3 strings  - binary 100 + 010 + 001
     sResult = s1 + sep + s2 + sep + s3; 
  break;
  default: // any missed combinations
     sResult = "";
  break;
return sResult;
var Addr1 = this.getField("Merchant_Addr1").valueAsString;
var Addr2 = this.getField("Merchant_Addr2").valueAsString;
var City = this.getField("Merchant_City").valueAsString; 
var State = this.getField("Merchant_State").valueAsString;
var Zip = this.getField(" Merchant_Zip").valueAsString;
var s = fillin(Addr1, Addr2, City, ", ");
var s = fillin(s, State, "", ", ");
event.value = fillin(s, Zip, "", "  ");
Or the custom calculation script could be reduced to:
// custom calculation script;
var Addr1 = this.getField("Merchant_Addr1").valueAsString;
var Addr2 = this.getField("Merchant_Addr2").valueAsString;
var City = this.getField("Merchant_City").valueAsString;
var State = this.getField("Merchant_State").valueAsString;
var Zip = this.getField(" Merchant_Zip").valueAsString;
event.value = fillin(fillin(Addr1, Addr2, fillin(City, State,"", ", "), "", ", "), Zip, "", "  ");
Do not forget the fillin function.

Similar Messages

  • Error in Adobe Java Script

    Hi,
    I am facing one issue while working in Adobe forms. My requriement is as follows.
    Two Drop down lists are there. Say Z1 and Z2. Z1 will contain three values.( A1, A2, A3).
    Assume for A1, the corresponding values  in Z2 are (1,2,3,4,5,6,8,10).
    Assume for A2,  the corresponding values  in Z2 are  (1,2).
    Assume for A3,  the corresponding values  in Z2 are  (4).
    By Default, A1 will appear in the Drop Down list Z1 and the corresponding values will be loaded in the Drop Down list Z2.
    Now, the issue is that if we select 5 in Z2, and then if we go and select A3 in Drop down list Z1, then this 5 is getting appended in the dropdown list Z2 with 4 and displaying as (4,5).
    But as per the selection, it should display only 4. This is happening in the cases only when the selected number in Z2 is not available in the current list of the selection from Z1. That is searching for unique entry.
    Please suggest how to clear the memory in adobe java script, before the next value selected from the drop down list Z1.
    Regards,
    Prabu.

    Hello,
    1) note there is Adobe forms forum under NetWeaver, you can find me and other Adobe people there
    2) check this:
    Populate drop-down from a second drop-down:
    Populating one Drop-Down list from the selection of another Drop-down list
    Regards Otto

  • Java script‐「GetTrackchange」について

    お世話になります。
    現在Win7にてInDesign CS5.5 を使用しております。
    「GetTrackchange」というスクリプトを
    adobeの公式スクリプティングガイドから見つけ出しました。
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/In DesignScripting/InDesign-ScriptingGuide-JS-JP.pdf
    このガイドの212ページ目のスクリプトです。
    そのページの指示通り、
    アーカイブからダウンロードした完全版スクリプトは、
    最下部の通りです。 
    このガイドによると下記のスクリプトにより、
    「トラックされた変更点に順次移動できる」ということです。
    さっそくこのスクリプトを実行すると、
    新らしくInDesignドキュメントが作成され、
    「This is a story.」の文字が入ったボックスが作成されます。
    何度実行してもこの操作が繰り返され、
    「既存のドキュメント内で、順次変更点に飛ぶこと」ができません。
    確かに記述でそのように書かれていそうですが、
    その部分を消去したり、真ん中のnextItem関連のブロックだけ残して実行しても、うまくいきません。
    adobeの窓口にも問い合わせましたが、
    スクリプト開発がアメリカのためらしく、
    有力な情報はいただけませんでした。
    Java scriptについては初心者でして、
    ここで質問させていただくことにずっと躊躇しておりました。
    しかしadobeの公式スクリプティングガイドのスクリプトであること、
    Web情報を一定期間念入りに調べてもまったく情報が得られないこと、
    adobeへの問い合わせでも有力情報が得られなかったこと、
    以上を踏まえましても、解決にいたらなかったため、
    恐縮ながら、こちらで質問させていただくことにいたしました。
    私が希望する動作が可能なようでしたら、
    皆さんのお力をお貸しいただけると嬉しいです。
    ※2行目にInCopyの記述がありますが、
    InDesign上のアーカイブからダウンロードしております。
    実際のスクリプト
    //GetTrackchange.jsx
    //An InCopy CS5 JavaScript
    //Shows how to get Track change from doc.
    main();
    function main(){
    mySetup();
    mySnippet();
    myTeardown();
    function mySetup(){
    function mySnippet(){
    var myDocument = app.documents.add();
        var myTextFrame = myDocument.textFrames.add({geometricBounds: [0, 0, 12, 12], contents: "This is a story."});
    myGetChangeFromDoc();
    function myTeardown(){
    function myGetChangeFromDoc()
        //<fragment>
    var myDocument = app.documents.item(0);
    var myStory = myDocument.stories.item(0);
    //Story.trackChanges   If true, track changes is turned on.
    if(myStory.trackChanges==true)
      var myChangeCount = myStory.changes.length;
      var myChange = myStory.changes.item(0);
      if(myChangeCount>1)
       var myChange0 = myStory.changes.nextItem(myChange);
        //</fragment>
    function myGetChangeFromDoc1()
    var myDocument = app.documents.item(0);
    var myStory = myDocument.stories.item(0);
    //Story.trackChanges   If true, track changes is turned on.
    if(myStory.trackChanges==true)
      var myChangeCount = myStory.changes.length;
      var myChange = myStory.changes.lastItem();
      if(myChangeCount>1)
       var myChange0 = myStory.changes.previousItem(myChange);
    なにとぞ、よろしくお願いいたします。

    これでどうでしょうか。
    #target indesign
    #targetengine "session"
    (function () {
        function getChanges (stories) {
            var changes = [];
            for (var i = 0, storiesLength = stories.length; i < storiesLength; i++) {
                var story = stories[i];
                Array.prototype.push.apply(changes, story.changes);
                var tables = story.tables;
                for (var j = 0, tablesLength = tables.length; j < tablesLength; j ++) {
                    Array.prototype.push.apply(changes, tables[j].changes);
            return changes;
        function selectItem (item, activePage, zoom) {
            app.activeDocument.select(item);
            if (activePage) app.activeWindow.activePage = activePage;
            if (zoom) app.activeWindow.zoomPercentage = zoom;
        (function () {
            var changes = getChanges(app.activeDocument.stories);
            if (changes.length === 0) {
                alert("変更が見つかりません");
                return;
            var index = -1;
            window = new Window("window", "");
            stext = window.add("StaticText", [0, 0, 100, 20], "");
            stext.justify = "center";
            var group1 = window.add("Group");
            group1.orientation = "row";
            var prevButton = group1.add("Button", undefined, "前の変更箇所");
            var nextButton = group1.add("Button", undefined, "次の変更箇所");
            var group2 = window.add("Group");
            group2.orientation = "row";
            var zoomCheck = group2.add("CheckBox", undefined, "ズーム表示");
            var zoomList = group2.add("DropDownList", [0, 0, 100, 20]);
            zoomList.enabled = false;
            zoomList.add("item", "50%");
            zoomList.add("item", "100%");
            zoomList.add("item", "200%");
            zoomList.add("item", "500%");
            zoomList.selection = 3;
            zoomCheck.onClick = function () {
                if (zoomCheck.value) zoomList.enabled = true;
                else zoomList.enabled = false;
            var select = function (index) {
                stext.text = (index + 1) + " / " + changes.length;
                var zoom = (zoomCheck.value) ? parseInt(zoomList.selection.text.replace("%", "")) : false;
                var change = changes[index];
                selectItem(change.storyOffset, change.storyOffset.parentTextFrames[0].parentPage, zoom);
            prevButton.onClick = function () {
                index -= 1;
                if (index === -1 || index < 0) index = changes.length - 1;
                select(index);
            nextButton.onClick = function () {
                index += 1;
                if (index === -1 || index >= changes.length) index = 0;
                select(index);
            window.show();

  • Adobe Dreamweaver CS5.5 - Windows 7 - Java Script Problem

    I am having trouble with Anchor.htm.
    When I try to insert an anchor in the text (Insert > Named Anchor> I get this error message:
    "While executing insertObject in Anchor.htm a Java Script error occurred."
    I recently downloaded both the 32- and 64-bit Java Script applications when I received a message that the existing version of Java Script was out-of-date. Anchor.htm worked before I installed the update.
    The files I downloaded and installed are:
    jre-7u9-windows-i586.exe
    jre-7u9-windows-x64.exe
    Please can anyone help me with this problem?

    From Dreamweaver FAQ
    http://forums.adobe.com/thread/429114
    "If Dreamweaver is acting erratically, or if you see a message saying "the following JavaScript error(s) occurred",  it's usually a sign of a corrupt cache file. The first thing to try should always be to delete the file cache. If that doesn't work, delete your personal Configuration folder. Full instructions are in Deleting a corrupted cache file.
    http://forums.adobe.com/thread/494811"
    Nancy O.

  • How to Debug Java Script in Adobe Form

    I have used an alert for empty fields . I have used Check button control for this.
    But the button click is very inconsistent. Some times it triggers the event sometimes it doesnt. Is there anyway to debug the java script. I have installed Script editor for IE but I am unable to use it for Adobe Forms.
    Any help is appreciated.
    Thanks,
    Vasu

    Hi Vasu,
    i think that maybe is the check sequence is not very correct.. and maybe you can try to code it one check for empty fields at a time..
    example
    Name.
    Address.
    Tel.
    Hp.
    Email.
    so u can try to code for one item at a time then slow try to debug it... as last time i use to insert the javascript inside each component then after it i implement into a button and slowly check for the check sequence which one need to be 1st and etc.
    hope it help you. if not maybe u can give more information. maybe i can help you out at myside.
    Regard,
    Ng Jia Jun

  • Need help with Java Script to perform a calculation in Adobe Acrobat Pro 9 form

    I have a form (test) that I am creating in Adobe Acrobat Pro 9.
    I need help creating custom Java Script so I can get the desired answer.
    1) There are several questions in each group that require a numerical answer between 0-4
    2) There is a total field set up to sum the answers from all above questions
    3) The final "score" takes the answer from Step 2 above and divides by the total possible answer
    Any help on what Java Script I need to complete this would be greatly appreciated!
    I've attached a "spreadsheet" that shows it in more detail as well as what formulas I used in Excel to get the desired end result.
    Thanks in advance.

    Have you tried the "The field is the average of:"?

  • Not only does Adobe flashplayer continue to crash on my operating system (windows 7) but now java script is having issues .... what is wrong with firefox????

    for months I have checked the forums, and seen the same issues with Adobe Flash Player ... I have uninstalled and reinstalled too many times now and am totally frustrated with Firefox,. I just get it working again and Firefox updates and then I have the same issues ... and now my java script is screwing up and it never did before .... this all came after the latest update .... is anyone else having these issues or is my operating system under attack???

    Recent crashes of certain multimedia contents (this includes Youtube videos, certain flash games and other applications) in conjunction with Firefox are most probably caused by a recent Flash 11.3 update and/or a malfunctioning Real Player browser plugin.
    In order to remedy the problem, please perform the steps mentioned in these Knowledge Base articles:
    [[Flash Plugin - Keep it up to date and troubleshoot problems]]
    [[Flash 11.3 crashes]]
    [[Flash 11.3 doesn't load video in Firefox]]
    Other, more technical information about these issues can be found under these Links:
    http://forums.adobe.com/thread/1018071?tstart=0
    http://blogs.adobe.com/asset/2012/06/inside-flash-player-protected-mode-for-firefox.html
    Please tell us if this helped!

  • Java Scripting in Adobe Acrobat Pro

    Company that I work for wants to create a form using Acrobat Pro with Java Scripting that allows access to data source. Is that possible? It is only being sent out to 350 people. Would we have to purchase LiveCycle still? Would really appreciate any input. Thank you

    Depends on a couple of things.
    Do you have Acrobat X Pro or Acrobat XI Pro?
    If you have Acrobat X Pro then you also have Adobe LC Designer and can use an XFA based form with OLEDB to connect to your data source.
    If you have Acrobat XI Pro then Adobe LC Designer is no longer included and you would be creating an AcroForm.  In that case then "No"  an OLE database source would not be directly available.  But you could use a webservice to achieve similar results with Acrobat JS if you were using a web server.

  • Java Script Adobe Acrobat 5.0

    O Adobe Acrobat 5.0 suporta java Script?
    O que eu posso fazer com o java Script dentro do Acrobat?
    Daniel
    [email protected]

    Acrobat 5 has been obsolete for more than 10 years! It sounds as if this was an upgrade looking for an even older version.
    Let's forget that and look at the problem with Adobe Reader. What is the problem there?

  • Java script created in Adobe Acrobat not working in Reader

    Hello,
    This is my first post, so I hope I chose the correct path for it
    Let's get to the point:
    I created a java script in Adobe Acrobat according to your tutorial page:
    search.matchCase = false;
    search.wordMatching = "BooleanQuery";
    search.bookmarks = false;
    search.query("Mytxt","Folder","../My directory");
    which I found to be working as a let's call it a relative link, beacuse, after copying my file into another folder it would still work. But when I opened the same file in Adobe Reader I got a Console message:
    Acrobat EScript Built-in Functions Version 10.0
    Acrobat SOAP 10.0
    GeneralError: Operation failed.
    Search.query:4:Link undefined:Mouse Up
    Folder does not exist
    As I mentioned before the same file does return the results of the search.query in this folder in Acrobat. Any ideas? Suggestions? What might be the problem?

    Thanks to your suggestion I started digging into the directories, so here's what's funny:
    Title Page - main folder
    Page 1 - sub folder
    Searched PDFs - sub sub folder
    I open the Title Page, then using a bookmark I open a new file in the same window: Page 1. There i have site links that allow me to perform search.query()
    And now to the funny part:
    In Acrobat:
    If I open the "Title Page" and from there go to Page 1 my directory has to be:
    ../Main Folder/Sub Folder/Sub Sub Folder
    to perform the required search
    However If I open the "Page 1" manually my directory for the same java script has to be:
    ../Sub Folder/Sub Sub Folder
    otherwise I get an error.
    Anyway
    Both don't seem to work in Reader....

  • Regarding usage of java script in adobe forms

    Hello experts,
                    Please any body help me out with what events i should use in java script / formcalc .
    send links for java scripting and formcalc.
    Thanxs,
    adi.

    The reference for Formcalc is available inside you designer installation directory.
    Like this one C:\Program Files\Adobe\Designer 7.1\Documentation\EN\FormCalc.pdf
    There you can also find general LifeCycle Designer Documentation (Designer.chm)
    In this file goto Creating Calculations and Scripts -> Events -> List of events
    As for JavaScript - reference is not in the package, so you have to search a bit. Something is available:
    Like this one: http://partners.adobe.com/public/developer/en/tips/CalcScripts.pdf
    Hope this helps!
    Regards,
    Petr Perstnev

  • Can't add java script to Adobe 7.0 PDF document

    Hi, ran into a small problem using Adobe Pro 7.0. Created a interactive form in Adobe Designer 7.0. Want to add Java script to run when a user selects certain fields on the forms. However, when I try and use the advanced editing tools to gain access to the Java script properties for that object, the toolbar is greyed out. No document security has been configured. Can this be done? Should it be done in Adobe Prof or in Designer? Can't figure out how to add the java script to the forms.
    Any help would be appreciated.
    Thanks Michael

    Once a form is started in LiveCycle Designer, it has to be edited in LiveCycle Designer. There are very few Acrboat features that can be used.

  • Condition verification in java script on Adobe form.

    Hello Experts,
    I am using a interactive forma text element on my view. (java web dynpro)
    It's a simple application. I am trying to figure out how it works with java script.
    I have a text field. which displays employ is sales or production dept
    the values in the data view and its the output element of a BAPI which returns XF,TF,HF and XK,JK,HK
    (record.dept)
    if its XF, TF, HF on the text field in the adobe form should print sales else production.
    I have never used java script on adobe form.
    I figured the strip above the form in adobe designer is used for java script.
    can any one, let me know how I can manipulate.  the record value
    Here is what I am trying record.dept = XF |TF|JF . but i dont know how to run the java script or its syntax.
    Your help is highly appreciated.

    James,
    xfa.host.messageBox should show you an alert dialog box to check data you are getting.
    And yes you are right. You can set the value of textfield using code you mentioned.
    if(record.dept.equalsIgnoreCase("XF")
                 || record.dept.equalsIgnoreCase("TF")
                          record.dept.equalsIgnoreCase("JF"))
       xfa.host.messageBox("The value is Sales");
       <Text-field id>.value = "Sales";
    else
       xfa.host.messageBox("The value is Production");
      <Text-field id>.value = "Production";
    You can even set the texfields to be readOnly, hide some of them etc. But for that I would suggest you going thru the LiveDesigner help. It would solve most of your doubts :-).
    Chintan
    Edited by: Chintan Virani on Feb 19, 2008 3:37 PM

  • Urgent !!! - Java script help for events in adobe form

    Hi ,
    We have requirement  where we have 5 buttons on interactive form which will retrive data from R/3 system .
    1) How can i distingish the event of each button  ?
    For Ex : We have 5 buttons namely , GetPlantcode , GetStatus, SubmittpSAP etc..
    We hav only 2 events on adobe form - Submit to SAP and SAPCheckFields.
    Please let me know some alternative by which i can sent some variable to webDynpro which distinguishes them.
    2) How to set a value for the context variable on button click event ?
    Ex : I have a context node ( data node ) bind to adobe interactive adobe component on a webDynpro application. If i want to set Selectindicator ( value attribute in data Node ) a value on a button click , Please let me know the java script how i can do this.
    Happy New Year for all
    Nanda

    Hi ,
    We found one work around for this. It seems to solve our issue for now.
    Set a text field on adobe and try to set it with some value in each button click. We can get retrived that value in webdypro application through context bind value node to text field.
    Using the value in the value node we have applied different logic in same event submit to SAP.
    Nanda

  • Installation of Adobe Flash 11.7.700.169 fails w/Java script errors

    I am getting very frustrated with Adobe software, it seems that nearly every time I try to update my flash player the update Flash player process fails with a java script error.
    I currently am running Adobe Flash player: 11.6.602.180
    My system is running 32-bit Windows XP, SP3, all patches to date, IE v8.0.6001.18702.
    When I try to install the Adobe Flash player update to 11.7.700.169 the process always fails with the following....
    A pop up to the screen from IE, titled: "Internet Explorer Script Error"
    The  message displayed on the screen is:
       An error has occured on the script on this page.
       Line: 1
       Char: 15965
       Error: Object Expected
      Code: 0
      URL: http://127.0.0.1/app/_js/adobe.js
    Do you want to continue running scripts on this page? <Yes>/<No>
    No matter what choice I make the install fails (choosing yes causes more Script Error messages to appear, before it finally hangs).
    I have followed the steps suggested on the 'Troubleshooting page', yes Active Scripts are enabled within IE
    I also have tried turning off all AV and Firewalls when performing installation, yet I get the same errors.
    Thanks,
    Mark Reynolds

    Download and run the offline installer from http://helpx.adobe.com/flash-player/kb/installation-problems-flash-player-windows.html#mai n-pars_header

Maybe you are looking for