Help Adobe javascript syntax

Hello

Greetings to all. I am a new to Acrobat javascript and the forum and should be grateful for pointers on a problem with a script that I write.

The script is automatically filled a text field (Text1) with a fixed number based on selections made in a combobox (ComboBox1) and control (Checkbox1) checkbox. ComboBox1 has 4 ads (DC, AC, BC, AX). Text1 should return the number 3 only if ComboBox1 <>DC and Checkbox1 = checked.

Individual conditions on their own works. If the below script returns a 3 in Text1

If (this.getField("CheckBox1").value! = 'Off') {}

Event.Value = 0.03;

} else {}

Event.Value = 0;

While this also returns a 3 in 1 text

If (this.getField("ComboBox1").value! = 'DC') {}

Event.Value = 0.03;

} else {}

Event.Value = 0;

However, when I have them unite, the script fails

If ((this.getField("CheckBox1").value! = 'Off') & & (this.getField("ComboBox1").value! = 'DC')) {}

Event.Value = 0.03;

} else {}

Event.Value = 0;

The problem does not seem to include syntax, but after having spent a lot of time looking at it do not see directly. What I am doing wrong?

Thank you very much

In all of your codes, you are missing the closing at the end brace...

If you encounter problems of syntax (like this), then it should be very obvious, because you will get error messages in the JS console when you change the value of any field.

If it is a problem of logic while there will be no error message, it will not work properly.

Tags: Acrobat

Similar Questions

  • Help with Javascript syntax for dynamic header / footer...

    Hello-

    I am very new to JavaScript, but I managed to frankenstein two snippets of code that work well individually, but I can't understand how to make them work together. I am applying a dynamic header and footer to a large number of documents using the batch. Here are two extracts that work, and if someone could help me to combine them, I would be very grateful!

    for (var pageNumber = 0; pageNumber < this.numPages; pageNumber ++) {var DateStamp = this.addField ("DateStamp", "text", pageNumber, [10, 15, 600, 0]);} DateStamp.textSize = 12; DateStamp.alignment = 'center'; DateStamp.textColor = color.gray; }

    this.setAction ("WillPrint", "this.getField('DateStamp').value = \"THIS DOCUMENT IS VALID FOR 24 HOURS from DATE of PRINTING:-"+ util.printd (" \"mm/dd/yyyy hh: mm tt\", new Date()) "");

    for (var pageNumber = 0; pageNumber < this.numPages; pageNumber ++) {var FilePath = this.addField ("path", "text", pageNumber, [10, 782, 600, 767]);} FilePath.textSize = 10; FilePath.alignment = "left"; FilePath.textColor = color.gray; }

    this.setAction ("WillPrint", "this.getField('FilePath').value = \"File path: \ "+ this.path");

    Thanks in advance for any help!

    The only problem is that your second order setAction is overwhelming the first. Simply combine it with a single command, as follows:

    this.setAction("WillPrint", "this.getField('DateStamp').value = \"THIS DOCUMENT IS VALID FOR 24 HOURS FROM PRINT DATE: \" + util.printd(\"mm/dd/yyyy  hh:MM tt\",new Date());  this.getField('FilePath').value = \"File Path: \" + this.path;");
    
  • Help with Javascript syntax error

    Hello

    I'm very new to all this. I have manged to write a script that will change the text in the field based on the text of another field. It sometimes "works", but the form freezes and crashes which I assume is because there is something wrong with my script. Any help would be appreciated.

    I put the script in the calculate-> custom calculation script box

    If ((this.getField("Email_Type").value == 'RSVP Reminder')) {}

    Event.Value = "Date:";

    }

    else if ((this.getField("Email_Type").value == 'Login Webinar')) {}

    Event.Value = "Date:";

    }

    else {}

    Event.Value = "";

    }

    I think I solved my problem. It looks like the place to check for each line, I need to declare the variable.

    If ((this.getField("Email_Type").value == 'RSVP Reminder')) {}

    Event.Value = "Date:";

    }

    else if ((this.getField("Email_Type").value == 'Login Webinar')) {}

    Event.Value = "Date:";

    }

    else {}

    Event.Value = "";

    }

  • Help! JavaScript works not when the object is moved from one page to the other!

    Hi all:

    I am new to Adobe Livecycle Designer (version 8.0). I created an interactive pdf form of 3 pages with many objects (text fields, radio buttons, drop-down lists, etc.), our company wants to quickly start to use.

    I'm having trouble with some of my Javascript does not not with some of my items on page 2 of the form. Specifically, there is a drop down menu to "Country" on page 2 of my form. When the user selects, for example, 'United States' in the list, I have the Javascript code that is supposed to change the 'currency' list drop-down to "Dollars" rawValue accordingly (on the change event).

    I think that my Javascript syntax is correct, but I am not sure. Here's my simple Javascript associated with the "Country" drop-down list (Note: rawValue 80 = 'United States' and 105 rawValue = "US $"):

    -


    Form1. Page1.cmbContactInfoCountry::change :-(JavaScript, client).


    If (this.rawValue == 80) {}

    cmbCurrency.rawValue = 105;

    }

    It sounds pretty simple and it WORKS when my "Country" drop-down list is moved to page 1 of the form, but it WON'T WORK when I move the combo box "Country" return to page 2 of the form (i.e. where it belongs).

    Anyone has suggestions or solutions? I spent probably 6-8 hours of racking my brain trying to figure out why it works when on a single page, but it does not work when to move to another page. I guess I can have corrupted something OR that I not address fully the proper name of the object?

    Help, please!

    Frustrated and helpless, near Chicago.

    Taylor T

    Yes, it's a quirk of... in the drop-down lists when you select an item in the DOF it is not committed until you exit the field, unless you do the following:

    If (this.boundItem (xfa.event.newText) == 1) {}

    cmbCurrency.rawValue = 1;

    }

    ElseIf (this.boundItem (xfa.event.newText) == 2) {}

    cmbCurrency.rawValue = 2;

    }

    The xfa.resolveNode stuff was not necessary that both objects are of the same subform, and as such can 'see' each other.

    Think like a folder structure subforms - elements can see what is in their own folder but will say where to find things in other folders. If cmbCountry was subform1 and cmbCurrency was so in subform2 that rawValue above lines would look like:

    subform2.cmbCurrency.RawValue = 1;

    It's a good idea to name all your objects, subforms, etc. it is to work with script is much easier - so you won't have to deal with things like these pieces of xfa.resolveNode you had before (as well). He ones because you have more than one subform called "subform", the number of hooks is the Instance number (when you have several of the same object) if the program has to differentiate between the various "subform".

    The number of instance come in handy, but for things like the rows of the table and so on when you need to make calculations.

  • Question 1: How do I add or use jQuery in folder level Adobe Javascript.  Question 2: How to write normal Javascript in file level Adobe Javascript ie., getElementbyid etc...  Please find the below code that shows what I am referring

    Here's my level Javascript file, which comes as a Pop up when I click on a created custom button in a PDF reader on your...

    I created a Test.js file and then pasted the code below into it. Then I copy paste this file in the following path: C:\Program Files (x 86) \Adobe\Acrobat 11.0\Acrobat\JavaScripts

    Now I want to know How to add jQuery Code or the Normal Javascript in the code below. Please give an example.

    Note: I do not use forms Javascript here. It is an ACROJS Javascript folder.

    Beginning of the Code

    app.addMenuItem ({cName: "PERSONAL INFORMATION", cParent: "File", cExec: "helloWorld()"});

    helloWorld = app.trustedFunction (function () {var

    app.beginPriv ();

    Dialog1 var = {}

    Description:

    {

    elements:

    [

    {

    type: "cluster."

    name: "invisible."

    align_children: 'align_left,

    elements:

    [

    {

    type: 'static_text. "

    name: 'First Name '.

    },

    {

    type: 'edit_text. "

    alignment: "align_fill",.

    Width: 300,

    height: 20

    }

    ]

    },

    {

    alignment: 'align_left,

    type: "ok_cancel."

    ok_name: "Ok."

    cancel_name: "Cancel".

    }

    ]

    }

    };

    app.execDialog (dialog1);

    app.endPriv ();

    });

    End of the Code

    Let's take a step back and understand what is 'normal' JavaScript. Normal to you probably means browser based, but it is only your point of reference. Any implementation of JavaScript includes at least the core JavaScript language, and that's what you have in the two Acrobat JavaScript, but also browser JavaScript. Things like the JavaScript syntax are dealt with in this part of the language, how are managed types (numbers, strings, arrays, classes,...), but also a number of items of library like for example the Date object. In addition to this basic language, almost all JavaScript implementations have a second part, which is the specific application. In the browser, you deal with HTML and windows and other things that have no meaning in the browser environment. In Acrobat, you work with PDF documents, annotations, form fields and more. The specific web browser Javascript is no more or less 'normal' that the implementation in Acrobat. It takes some getting used to a different environment, and what is the Acrobat JavaScript API reference. You will find all the specific objects in Acrobat and methods described in there. What makes things a little more difficult for you, is that you probably don't know corresponding to the line between the core language and browser-specific extensions, so you'll have some re-learning the language in front of you.

  • timeoutScript and Javascript syntax

    Migration of Flash and new Director - I want to implement a splash screen - I know and like javascript syntax, I know that there are examples of jargon.

    In view of the scarcity of literature on timeoutScript - I tried various permutations of the following without result.

    I just run this from the authoring environment, in the case where that matters.

    function showSplash()
    {
    trace ("showSplash ()"); I never see this!
    }
    StartMovie() function
    {
    trace ("loading succeeded"); Appear fine
    timeoutScript = "showSplash;
    timeoutLength = 60;
    }

    Any help would be appreciated.

    Sean:

    Thank you very much.

    Works with two film scripts as you suggest.

    Thought I was missing something obvious to do not be able to process the timeoutScript.

    Thanks again,

    Tim

    ////////////////////////////////////////////////////////
    First film script is in javascript
    //
    function showSplash()
    {
    trace ("showSplash ()");
    .. .this now works...
    }

    StartMovie() function
    {
    SetUpScreenSaverTimeout();
    }

    --Deuxieme movie script is in the jargon
    --
    on SetUpScreenSaverTimeout
    timeoutLength = 60 * 5
    the timeoutScript = "showSplash.
    end

  • How to connect to an Adobe Javascript(Folder Level Script) SAP Web Service and retrieve the response in a table of the Adobe Javascript/AcroJS. Could you please it explain with an example. I have two required input parameters that must be filled.

    How to connect to an Adobe Javascript(Folder Level Script) SAP Web Service and retrieve the response in a table of the Adobe Javascript/AcroJS. Could you please it explain with an example. I have two required input parameters that must be filled.

    I s generic SOAP example/tutorial on my blog: get a serial number in a form using SOAP - KHKonsulting LLC

    The web service uses only a single parameter, but you should be able to adapt the code to two arguments without problems.

  • Photoshop crashes soon after startup. How can I obtain and present the crash log? When I go to 'Help-&gt; Adobe product improvement Plan' nothing happens.

    Hello

    I'm having the problem that my Photoshop CS6 always crashes soon after startup. I use no plug-ins, and my PC is in good health. I would like to present a crash log if someone can tell me what the problem is, but when I go to 'Help-> Adobe product improvement Plan' that I read is where crash logs are produced nothing happens.

    I also have a question my Premiere Pro hangs at startup upward. I have these two programs were widely used in the past but have recently started having problems. I have already uninstalled and reinstalled CS6, but the problem persists.

    Any help would be massively appreciated.

    Chris

    Thank you. The crash log tells me that you have not updated Photoshop CS6. It should be 13.0.1.3 not 13.0.0.0

    Either run help > updates or download and install it. Adobe - Photoshop: for Windows

    ig75icd64.dll is a display driver.  Go here and to update: Intel® Driver Update Utility

  • Documentation on the Adobe JavaScript API?

    AgentNiles wrote:

    Is there some sort of API where I can read more about these wonderful Adobe javascript implementations?

    Ditto for this!

    Branched out in a new thread, it was a response to a message from 3 years.

    See Digital Publishing Suite | Adobe Developer Connection. Specifically, look at the bottom of the page and it has a link to the documentation Library SDK and the read API documentation.

    Neil

  • Adobe Javascript from Excel VBA

    I have some have little experience with VBA Excel and Adobe Javascript separately, but I never tried to put it together. I'm quite baffled by the use of 'DoJavaScript' from in Excel VBA. I have a number of JavaScripts Illustrator that do various tasks (for the most part, measure and set properties on illustrator objects to determine geometric measures). I wanted to run these scripts from Excel VBA (they run smoothly when it is called directly in Illustrator). My hope was to spend some real numbers of VBA in the JavaScript code before we ran to set some performance parameters and get some real numbers back out the JavaScript in VBA. I can't get even the simple DoJavaScript given command in Adobe VBscript reference to run. Read other messages that seem somewhat related that it is unclear if I hurt something very simple, or if my understanding of the use of the DoJavaScript command is incorrect. Is anyone able to shed some light on this?

    My last try was this simple test... almost directly from the reference from Adobe:

    Private Sub SetScale_CommandButton1_Click()

    Set appRef = CreateObject ("Illustrator.Application")

    Set myNumberOfDocuments = appRef.DoJavaScript("documents.length;")

    MsgBox myNumberOfDocuments

    End Sub

    I really hope to be able to run javascripts that are a few hundred lines long..but, even if I can't get something simple to go so I'm about to give up on this.

    Thanks for your suggestions

    I got type mismatch error, to make your sample work, simply remove the "second".

    Private Sub SetScale_CommandButton1_Click()

    Set appRef = CreateObject ("Illustrator.Application")

    myNumberOfDocuments = appRef.DoJavaScript("documents.length;")

    MsgBox myNumberOfDocuments

    End Sub

  • Please, do I have with the help of Javascript can change the values of tones? for example my color of nail POLISH with c: 0, m:10, y: 15, k: 0 to change to c: 0, m:0, y: 0, k: 0? Thank you

    Please, I beg you, with the help of Javascript change the values of specific spot color? for example, I have the color called VARNISH with c values: 0, m:10, y: 15 k: 0 and it would help me to change to c: 0, m:0, y: 0, k: 0, in an action. Is this possible? Thank you

    Hello Kon Verter,

    You can change the values in your sample of spot, but you need to check a lot of things before.

    for example, you can do something like this:

    var Vcolor = app.activeDocument.swatches.getByName("Varnish");
    if (Vcolor.color.spot.colorType == ColorModel.SPOT && Vcolor.color.spot.spotKind == SpotColorKind.SPOTCMYK) {
        alert("Black value before: "+Vcolor.color.spot.color.black);
        Vcolor.color.spot.color.black= 0; // and so on
        alert("Black value after: "+Vcolor.color.spot.color.black);
        }
    

    This will change the black value of the task of CMYK color with name Nail Polish 0

    Have fun

  • Need help adjusting Javascript code in Adobe Edge (Countdown)

    Hello

    Im a beginner when it comes to working with Javascript and Adobe Edge and need a bit of help with setting of javascript code to work with Adobe Edge. A friend of mine helped me to make this javascript code: Edit fiddle - JSFiddle
    Its a countdown simple countdown to a certain time at a certain date. What I want to do is add this code as a trigger on a text called "countdown" element (inside a symbol called "count").

    I tried to do what the code is, but it does not work. Someone at - it suggestions?

    Thank you!

    MVH,

    Paul Hermans

    You have a private message with a countdown on my own model.

    I gave your link (Edit fiddle - JSFiddle): code ==> free free numbers.

  • Please help with a basic javascript syntax

    Can anyone help me please with an installation of 'remove from Favorites', I'm working.

    I have query to get all the favourites, and then I pulled out the Favorites to the bottom of the page

    Each favorite has a link 'remove from Favorites' - I want to make sure that when a user clicks on this link, they get a javascript confirm box pop up saying "are you sure you want to delete #favourites name # of your Favorites?

    So I have...

    function remove(profile,name) {}
    If (confirm ("are you sure you want to delete #name # your Favorites?")) {
    Window.Location = "remove_from_favourites.cfm? deleteFavID = #profile # & removedName = #name #
    }
    }

    and

    < div onClick = "remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)" > remove from Favorites < / div > "

    but it does not work - I think that there are 2 problems...

    problem 1 - I used CF # in the suppression works as I don't know what we're doing in javascript for "output" a variable (see where it says "Are you sure you want to remove #name # favorite") what should I use instead of ' # '?

    problem 2 - I tried to pass to the function variables > > onClick = "remove(#rs_favs.favouriteeID#,#rs_favs.firstName#)" and I separated the but a commercial "," but I suspect that it is an incorrect syntax "


    If someone could please help me I would be very grateful to be honest, I like coldfusion - but javascript hurt just my head! :(

    Thank you very much.

    PS how I wrapped my text 'remove from Favorites' in a div rather that to make a link real 'a href' - is that correct or is there a better way (ideally I want the text to look like all my other links (ie they emphasize on mouse over))

    It's because you pass a value of string without single quotes in your onclick() function.

    To take

    Remove Favorites

  • Help with Javascript Code

    I have need of a few write him a fast JavaScript code. I have no experience in JavaScript, but enough to know what to understand. I'm helping to write a very simple writable document in Adobe Acrobat Pro. We need a code which would be specific when a checkbox is clicked on it auto fills with information in the other text boxes. In other words: If mailing address is the address of work so she fills out this information. I have included my variables with the correct names below.

    Thank you for taking the time. Can anyone help?

    I need something that will:

    If checkbox = 'On '.

    then 'employment Address1' = Address1

    then "employment Ville1" = Ville1

    then 'employment State1' = State1

    then 'Job postal Code' = Zip Code 1

    then 'employment County' = County1

    then 'job City, State Zip1' = city, State Zip1

    on the other

    If checkbox = "Off".

    each the first variables remains empty and accessible writing.

    Double readings:

    this.getField("Job_State1").value; = this.getField("State1").value;

    has a semicolon which it does not belong. The line should read:

    this.getField("Job_State1").value; = this.getField("State1").value;

    Then all of the code is:

    If (event.value! = "Off") {}

    fill in the fields of employment;

    this.getField("Job_Address1").value = this.getField("Address1").value;

    this.getField("Job_City1").value; = this.getField("City1").value;

    this.getField("Job_State1").value = this.getField("State1").value;

    this.getField("Job_Zip_Code").value; = this.getField("Zip_Code1").value;

    this.getField("Job_County").value; = this.getField("County1").value;

    this.getField("Job_City,_State_Zip1").value; = this.getField("City,_State_Zip1").value;

    else {}

    Clear fields;

    this.getField("Job_Address1").value = "";

    this.getField("Job_City1").value; = "";

    this.getField("Job_State1").value; = "";

    this.getField("Job_Zip_Code").value; = "";

    this.getField("Job_County").value; = "";

    this.getField("Job_City,_State_Zip1").value; = "";

    }

    You need to find how to set each field if only one is updated. The combined field may need to be updated by each field component. I use the blur action on and avoid using personal calculation action.

  • Helps validation JavaScript signatures based on an amount of form

    Greetings,

    First of all, I have no experience with JavaScript.

    I have a PDF (Adobe Acrobat X Pro) form with a dollar amount.  Based on this amount, a certain signature (text box) must be completed.  On the mouse to the bottom of the action for the button Save the form, I need to validate that there is an entry for the correct signature (again, according to the dollar amount).

    My low pseudocode for this would be:

    If (dollarAmount > 0) and (dollarAmount < 100) and (signature1 == "") then printToScreen ("Signature1 requires")

    ElseIf (dollarAmount > 101) and (dollarAmount < 200) and (signature2 == "") then printToScreen ("Signature2 requires")

    ElseIf (dollarAmount > 201) and (signature3 == "") then printToScreen ("Signature3 requires")

    Any help would be appreciated.  Thank you.

    This script will do what you describe in your pseudocode, but be aware that it does not handle the following situations:

    -dollarAmount is empty

    -dollarAmount is exactly 100

    -dollarAmount is exactly 200

    var dollar = + this.getField ("dollarAmount") .value;

    var signature1 = this.getField("signature1").value;

    signature2 var = this.getField("signature2").value;

    var signature3 = this.getField("signature3").value;

    If (dollar > 0 & dollar)<>

    If (signature1 =="") {}

    App.Alert ("requires Signature1");

    }

    } ElseIf (dollar > 101 & dollar)<200)>

    If (signature2 =="") {}

    App.Alert ("requires Signature2");

    }

    } ElseIf ($ > 201) {}

    If (signature3 =="") {}

    App.Alert ("requires Signature3");

    }

    }

Maybe you are looking for

  • Satellite L505 don't dΘmarre

    My laptop does not start after receiving a bit of a sudden keyboard. Given the nature of the case, I guess it's a hardware problem... I opened and examined all the elements but could find no cracking or bumps into what. Since the problem began, I can

  • Lenovo Thinkpad Yoga X 1 touch screen does not work

    Hi all I just bought a brand new Thinkpad Yoga X 1 and out of the box, the touch screen is not recognized by windows and no entry through fingers or via pen works. I would be very happy if someone could tell me if it's just a wrong settings or if the

  • How to configure the Windows XP firewall to allow access for Windows 7

    I have 2 Windows 7 PCs & 1 Windows XP. XP, I can connect & see the shared folders on the 7.  However, I don't see the XP from 7 if I disable my firewall. They are all connected to the same workgroup.  I removed the 7 s residential groups (that I read

  • B8320 and blackBerry Smartphones yahoo mail

    Hi all I have a bb 8320 and I want to read... send my e-mail address in my bb... How can I do? I expect your idea... Thank you

  • BlackBerry Smartphones Blackberry Desktop Software said 'connection '.

    I'm trying to back up my blackberry and it keeps saying for the last 30 minutes connecting to the right of the bottom of the screen.  It shows my camera but I can't click on the tab now backup and when I go to configure settings it tells me to connec