Using a choice of multiple words in a drop-down list field to launch a java script

I'm a complete newbie to manuscript of java and relatively new to your building in Acrobat.

I use a drop-down list field to fill in automatically other fields based on my 1st drop-down list selection.

The 1st field drop-down allows me to select a variety of suppliers.  Once I have selected the vendor, he auto-remplit the coordinates for this provider.

I've plagiarized the writing of scripts from this link: https://acrobatusers.com/tutorials/change_another_field.  I even changed my domain names for the moment.  I'll change my return form field names and the script to match once I got it working like I want.

If I use only one name in my drop down list provider (1 field), the script works perfectly and auto-remplit contact as expected information.  However, many of my suppliers are two words or more... and I need those names in print, so I can't do just a contraction of a Word.  Here is the script I use:

Here is an example of a supplier of single word name that works as expected:
Put all vorkriegsbevölkerung data in a single data structure
var DeptData = {ADLEMI: {contact: "P.O. BOX 2371",}}
E-mail: "DOWNEY, CA 90242."
{{deptnum: "PHONE: (562) 923-0333 FAX: (562) 923-8111 '}};
function SetFieldValues (cDeptName)
{
this.getField("DeptContact").value = DeptData [cDeptName] .contact.
this.getField("DeptEmail").value = DeptData [cDeptName] .email;
this.getField("DeptNumber").value = DeptData [cDeptName] .deptnum;
}

Unique provider name, I used in the example above is "ADLEMI."  If I add 'BEST' to ADLEMI (see below), I get a syntax error.  I really need to be able to use several words in my list drop-down provider to trigger auto-fill.

Put all vorkriegsbevölkerung data in a single data structure

var DeptData = {ADLEMI BEST: {contact: "P.O. BOX 2371",}}

E-mail: "DOWNEY, CA 90242."

{{deptnum: "PHONE: (562) 923-0333 FAX: (562) 923-8111 '}};

function SetFieldValues (cDeptName)

{

this.getField("DeptContact").value = DeptData [cDeptName] .contact.

this.getField("DeptEmail").value = DeptData [cDeptName] .email;

this.getField("DeptNumber").value = DeptData [cDeptName] .deptnum;

}

The only difference is that I added a space and the word 'BEST' after ADLEMI.  Is there a way to get around this.  I need to have several words in my drop-down list, or at least the full name of the vendor indicating in the field when I print it.

Thank you

Place quotation marks around the name of the element.

Monday, April 13, 2015, at 17:29, bpwhistler, [email protected]>

Tags: Acrobat

Similar Questions

  • Showing and hiding of multiple tables with a drop-down list

    I'm doing a drop-down list so that users can select the number of tables that are shown/generated when they specify the tables how they need to complete (there is 1 table for each day of a multi = day, maximum of 5).

    I thought I would use a similar javascript than I used in another place on the form that has been applied to radio buttons to show or hide a specific table. When I applied that to the drop down and added more than lines that the scipt was ineffective, with some play that I managed to do the work, but now it seems thre is a question with which value is selected in the list. When a user selects a certain value, it shows the previous value (so when I chose 4 days, which has a hairy '3', the message box for the test proposed, I added told me I selected the value '2').

    I wonder if there is an easier way to do the function, what I'm doing, or if the drop down menu is the best solution? The maximum number of tables that can be filled is 5, then the drop down menu appears as a way ideal for resticting than for the person filling out the form.

    This is an example of writing, that I joined the drop-down list, as an action of "change." It is repeated 4 times for each value.

    Form1. Page2.DropDownList1::change - (JavaScript, client)

    If (this.value == '2') {}

    Form1. Page2.TableDay1.presence = "visible";

    Form1. Page2.TableDay2.presence = "visible";

    Form1. Page2.TableDay3.presence = 'hidden ';

    Form1. Page3.TableDay4.presence = 'hidden ';

    Form1. Page3.TableDay5.presence = 'hidden ';

    }

    else {}

    Form1. Page2.TableDay1.presence = 'hidden ';

    Form1. Page2.TableDay2.presence = 'hidden ';

    Form1. Page2.TableDay3.presence = 'hidden ';

    Form1. Page3.TableDay4.presence = 'hidden ';

    Form1. Page3.TableDay5.presence = 'hidden ';

    }

    If (this.value == '3') {}

    Form1. Page2.TableDay1.presence = "visible";

    Form1. Page2.TableDay2.presence = "visible";

    Form1. Page2.TableDay3.presence = "visible";

    Form1. Page3.TableDay4.presence = 'hidden ';

    Form1. Page3.TableDay5.presence = 'hidden ';

    }

    else {}

    Form1. Page2.TableDay1.presence = 'hidden ';

    Form1. Page2.TableDay2.presence = 'hidden ';

    Form1. Page2.TableDay3.presence = 'hidden ';

    Form1. Page3.TableDay4.presence = 'hidden ';

    Form1. Page3.TableDay5.presence = 'hidden ';

    }

    I looked at it and tried a few different things and my colleague who is much better than me with sciprting is also at a loss for now - he is unfamiliar with LiveCycle, unless I have so any help is appreciated. Thanks a lot once again as my last number (the script for radio buttons) has been resolved here. Thanks again.

    The question that you see with the value being off is due to the fact that you use the change event. The change event is triggered * before * the new value is assigned to the field. This event is commonly used for intercpet changes. If you wish to continue using the change event, you can get the new value with:

    xfa.event.newText;

    This, however, will get the text that is displayed instead of the value behind. No doubt, you can consult the nodes in the drop-down list to see what value, but I think you should just avoid all of this by adding your code to the layout event: each subform hideable... loan for example, for the first, in the case of TableDay2 layout_ready (as the day1 should never be hidden, as I understand it) put :

    This.Presence = (DropDownList1.rawValue > = 1)? "visible": "hidden";

    TableDay3 would be:

    This.Presence = (DropDownList1.rawValue > = 2)? "visible": "hidden";

    etc.

    Let me know if it helps.

    -Scott

  • Using the API to control the visibility option drop-down list

    We have by using a web service to generate an interview of a modules. The modules a drop lists in which the drop down options are linked to attributes of visibility down. Our question is: How do access us these properties of visibility in the API?

    We found an optionliste with the signature method: IsVisible (entityInstance, InterviewSession session InterviewEntityInstance). We do not know what is InterviewEntityInstance or how to use it.

    Are we on track?

    Thank you.

    Hello

    Yes, you are on the right track. Unfortunately, this part of the API is much finer grain than is really desirable, it takes a bit of work to evaluate the expression of visibility. Basically the code in order to evaluate the visibility attribute looks like:

           //this code assumes the variable 'ctrl' is the AttributeInputControl to which the list options are attached
           InterviewEntityInstance entityInstance = new InterviewEntityInstance(ctrl.getRawEntityId(), ctrl.getRawEntityInstanceName());
           InterviewSession session = ctrl.getScreen().getInterviewSession();
    
            List options = ctrl.getListOptions();
    
            for(Object o : options){
                ListOption opt = (ListOption)o;
                boolean visible = opt.isVisible(entityInstance, session);
    
                //Do something
            }
     
    

    There is also a known issue that assess the visibility of the list of options for the controls on a screen entity collect will cause an exception. 10.2 this issue has been addressed and the API has been simplified to ListOption.isVisible ().

    Thank you
    Kristy

  • Don't want to use a drop-down list field

    I use a text box I want only user can enter into an 'a' or a 'd', how do I make this happen?

    Thank you

    Add the following function to a JavaScript script at the level of the document and call it from event hits the field:

    function AorD_ks() {
    
        // Get everything that's entered in the field
        var val = AFMergeChange(event);
    
        // Allow a blank field
        if (!val) return;
    
        // Reject everything other than a or d, or A or D
        event.rc = AFExactMatch(/^(a|d)$/i, val);
    }
    

    Remove the i in the regular expression if you don't allow uppercase.

    He didn't really need is that it's what you want, but to show a good generalist.

  • Automatically populate a drop-down list by using another selection from the drop-down list box

    New java/preparation forms so I apologize in advance.

    I currently have a menu drop-down box 1 (Occupation) with three options: "enter your own description/blank", retired housewife. When someone chooses either retirement or anyone at home, I would another drop box 2 (employer) to assign automatically "n/a. . The employer drop box has only two options: "enter your own/blank", N/A.

    Far, I could for that box to fill but only when the person clicks in the box (as if they were about to enter their own text.) Then only it will fill the drop-down list "employer." I would like it auto fill once the person has chosen retired, Virgin or stay-at-home woman without having to enter in the box (just using the arrow to the size of the drop-down list box).

    I currently have a key shot that resets the employer box when a person chooses the option vacuum/enter your own option. I then a JavaScript (only for the housewife now) that only works if you click the box of. Key combination works I want to than the other options work as well. If the client settles on white, the choice of the employer updates automatically empty without having to click in the box of. Any help (including general advice to make my code cleaner) is very appreciated!

    Current script of typing:

    If {(event.willCommit)

    If (event.value == "") this.resetForm (["use"]); of other SetFieldValues (event.value);

    }

    The current upward, mice running JavaScript :

    var v = this.getField ("Occupation") .value

    If (v is "Housewife")

    1. this.getField("Employer").value = "N/a".

    I think maybe I should use event.willCommit in my formula, but I'm not sure how to include it.

    Thank you!

    I would not use the key sequence or MouseUp actions for this, but the action post.

    Just make sure that you set the field option to validate the selected value immediately (under Properties - Options) and then use this code as the custom validation script:

    var employerField = this.getField("Employer");
    if (event.value=="Homemaker" || event.value=="Retired")
        employerField.value = "N/A";
    else employerField.value = employerField.defaultValue;
    
  • How do complete you 1 text box with multiple drop-down list values

    I can fill in a text box with a value in a drop-down list, but if I have 2 drop-down list values going to the same area of text (multiple lines), the second drop-down list value removes the first value.

    (A similar code on the drop-down list 1 and 2 from the drop-down list)

    Change event - JavaScript

    If (xfa.event.newText == 'No') {}

    Form1.Page1.subform2.Description.RawValue = "no location listed.

    }

    If (xfa.event.newText == "Partial renting") {}

    Form1.Page1.subform2.Description.RawValue = "enumerated part place."

    }

    Do I have to Concat the fields in 1 text field so that it can have several values in drop-down list, and if so how do I do that?

    Thanks in advance for your help.

    Resolved:

    Place this script in the root of the subform in the FormReady - JavaScript event.

    oList var = this.getDeltas ();

    for (i = 0; i< olist.length;="" i="">

    {

    var oDelta = oList.item (i);

    oDelta.restore ();

    }

    Answer was found at http://forms.stefcameron.com/2008/09/29/restoring-the-of-your-form/

  • JavaScript to set radio button choices using the drop-down list box value.

    I use Adobe Acrobat Pro DC version 2015.016.20039 on a MacBook Pro OS X El Capitan version 10.11.6.

    I have a set of named CitBox radio box choices. I'm defining what choice is selected from out of a drop-down list named AppCitizenship box.  Both of them have six choices with values of 1, 2, etc. (I thought having the same values would make easier the translation from one to the other). Thanks in advance.

    If you used the same values, then it is pretty easy. Just use this code as the validation script custom field drop-down list:

    this.getField("CitBox").value = event.value;

  • How to return multiple screens? There used to be a drop-down list of the recent screens in a tab. Thank you.

    The navigation bar contains icons arrow to move forward or backward a screen in a tab, but previous versions of Firefox has also provided a drop-down list of recent Web pages allowing the user to return more than one screen with a single click. This feature is always available?

    The feature was not removed, see article #5 tools rear without drop-down - menu bar button use right-click (or left click hold for a second) for the drop-down list

    in what follows:

    You can make Firefox Firefox 5.0 look Firefox 3.6.19, paragraphs numbered 1 to 10 in the next topic difficulty Firefox 4.0 UI toolbar, problems (Make Firefox 5.0, or 4.0.1 resemble 3.6). If you make changes, you must be aware of what has changed and what it takes to use changed or missing features.
  • Multiple drop-down lists using SetFieldValues mixture fields.

    I have 2 drop-down lists (Dropdown1 & Dropdown2). They are identicle except for their domain names and of their first element option.  When the user chooses an option, I want a predetermined value to be sent to a field of text (FeeAmountRow1 & FeeAmountRow2).  Similar to a purchase order using a drop down.

    By trial and error what I know is that somewhere my scripts are cross.  When I try the shape as the script below, the two drop-down lists send values in the same text instead of their respective field.  Removal of code in each menu drop-down makes the job of other fines.

    I made each of them 'value selected to validate immediately '.  I added the following Scripts of striking personalized to their format.

    Dropdown1 - text if field resets the default drop-down list option is selected, this feature works very well.

    if (event.willCommit) {
        if (event.value == "Select Day 1 Service Type") this.resetForm(["FeeAmountRow1"]);
        else SetFieldValues(event.value);
    }
    

    Dropdown2

    if (event.willCommit) {
        if (event.value == "Select Day 2 Service Type") this.resetForm(["FeeAmountRow2"]);
        else SetFieldValues(event.value);
    }
    

    I use the following script:

    // Dropdown option items data 
    var saData = {
        "Speaking Engagement": {
            fee: "1360.00"
        },
            "Field Ride Consultation": {
            fee: "1700.00"
        },
            "Speaker's Training": {
            fee: "1500.00"
        }
    };
    
    function SetFieldValues(saName) {
        // Populate fields with values
        this.getField("FeeAmountRow1").value = saData[saName].fee;
        this.getField("FeeAmountRow2").value = saData[saName].fee;
    }
    

    In the SetFieldValues function, it is exactly what the code does. He defined two different fields to the same value. Create a separate for each field feature individual rtext, or pass the name of the field as a parameter. For example:

    function SetFieldValues(f_name, saName) {
        // Populate fields with values
        this.getField(f_name).value = saData[saName].fee;
    }

    New script from typo to dropdown2
    if (event.willCommit) {
        if (event.value == "Select Day 2 Service Type") this.resetForm(["FeeAmountRow2"]);
        else SetFieldValues("FeeAmountRow2", event.value);
    }

  • Deletion of a single list in the drop-down list of choices

    Maybe I just don't see the simple solution, but how do I give a user the ability to simply remove his choice in a drop-down selection list. I have added a clear form button to clear all form data, but how do I allow the user once he or she has selected an item in a drop-down list to just go back and remove any choice of an element of the single drop-down list? Actually I think that this should be possible with all the elements of shape, right?

    With the "resetForm" javascript command, you can specify a single field or multiple fields to zero. Add this event to the button action and replace "Combo Box1" with the names of the fields that you want to reset:

    this.resetForm ("Combo Box1") / / resets only Combo Box1

    Alternatively, you can use one of the following conditions:

    this.resetForm (["Box1 Combo", "Box2 Combo"]) / / resets only Combo Box1 and Box2 Combo

    this.resetForm () / / resets the entire form

  • How to use a function switch box to the reference that is used several times in the previous drop-down list options?

    I use JavaScript coding in LiveCycle and development of dependent drop-down areas, but I find it difficult to write correct code. See the example below. I'm trying to use a multiple box function that refers to an option that is listed several times in the previous pull-down menu. The problem I am running into is that when I refer to any color or Nissan and Chevy, it returns the results of the color in the "Ford" column only. I'll always see color (blue, black, green and purple) options in my second drop-down list and it seems fine, but then the third drop reference only the options and colors 'Ford '. (I don't have the code for the third menu list drop-down).

    I want the client to choose Chevy or Nissan and have her drop downs (based on the color they chose)-dependent, but I can't seem to make this work.

    I hope it is clear enough (probably as mud...). I would appreciate help!

    Form1. #subform [0]. #subform [1]. cboModels::exit - (JavaScript, client)

    cboColor.clearItems ();

    {Switch (this.) RawValue)}

    case "Ford":

    cboColor.addItem ("Blue");

    cboColor.addItem ("Black");

    cboColor.addItem ("Green");

    cboColor.addItem ("Purple");

    break;

    case 'Chevy ':

    cboColor.addItem ("Blue");

    cboColor.addItem ("Black");

    cboColor.addItem ("Green");

    cboColor.addItem ("Purple");

    break;

    case "Nissan":

    cboColor.addItem ("Blue");

    cboColor.addItem ("Black");

    cboColor.addItem ("Green");

    cboColor.addItem ("Purple");

    break;

    }

    Form1. #subform [0]. #subform [1]. cboColor::exit - (JavaScript, client)

    cboPrice.clearItems ();

    {Switch (this.) RawValue)}

    case "Ford":

    case "green":

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    break;

    case 'Chevy ':

    case "green":

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    break;

    case "Nissan":

    case "green":

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    cboPrice.addItem ("blah");

    break;

    }

    You can use '\n' for newline in a string, so

    "Option 1, \nOption 2, \nOption 3;

    Put each on its own line.

    Bruce

  • How to use Javascript to populate a text field based on a selection in a drop-down list?

    Greetings,

    I have virtually no experience with JavaScript and I'm trying to find a way to add some functionality to basic Automation to a form of Adobe.  I have a drop down box called "Hospital_Name" which will contain about 7 possible selections.  When the user makes a selection, I would like to have the field of text (called "Hospital_Address") under the drop-down list fill with the corresponding address to the selection.  I have the "Hospital_Address" text field set up for multiple lines and want the address to have a line break between the address and the city/province/postal code.

    For example, if the user has selected "Hospital 1", the text field would display:

    123 main St

    Anytown, CA 12345

    Help or you can provide examples would be greatly appreciated.

    'Re missing you the document level script that sets the data object and setItems function.

    document level JavaScript; Could be placed in the action open to the page if you cannot access the document JavaScripts level;

    Place all the pre-population data into a single data structure
    var Location = {}
    ' - Hospital - ': {line1: "', line2:" "" "},
    'Bellevue Medical Center': {line1: "2500 BMC Drive", line2: "Bellevue, NOT 68123"},

    "CHI Bergan Mercy": {line1: "7500 mercy Road", line2: "Omaha, NOT 68124"},
    'CHI Emmanuel': {line1: "6901 N 72nd Street", line2: "Omaha, NOT 68122"},
    'CHI Lakeside': {line1: "16901 Lakeside Hills Court", line2: "Omaha, NOT 68130"},

    'CHI Midlands': {line1: "11111 s. 84th Street", line2: "Papillion, DON'T 68046"},
    'Creighton University Medical Center': {line1: ' 601 n. 30th Street ', line2: "Omaha, NO 68131"},
    'Nebraska Medical Center': {line1: "4400 Emile Drive", line2: "Omaha, NOT 68105"}
    };

    function SetFieldValues (Hospital_Name) {}
    location [Hospital_Name] .line1 = this.getField("AddLine1").value;
    this.getField("AddLine2").value = location [Hospital_Name] .line2;
    }

    end document level scripts;

    custom script hits;

    If {(event.willCommit)

    If (event.value == "") this.resetForm (["AddLine1", "AddLine2"]); of other SetFieldValues (event.value);

    }

    end of custom keystroke script;

    Note the formatting of the elements in a column as a line we can help revise the code. Also use a text editor for processing code.

  • Hello experts, I use Adobe forms in SAP. My question is, is there a any restriction for additem keyword in JavaScript? I mean, even if I use the keyword additem to add the name and value of a drop-down list, it adds up to 10000 files only. Please s

    Hello experts,

    I use Adobe Forms in SAP.

    My question is, is there a any restriction for additem keyword in JavaScript?

    I mean, even if I use the keyword additem to add the name and value of a drop-down list, it adds up to 10000 files only.

    Please sugest

    A drop-down list is the bad INTERFACE design where an element can contain more than 100 entries. It is very good in tests, but absolutely unacceptable if the form must be used by a person busy doing their work. The choice of Acrobat forms are limited, but consider a list box. Despite this, there may be limits imposed by the system or the implementation.

    Better would be

    (a) stop filling after awhile the list and add an entry saying several elements not shown, running report or use better filter

    (b) be available for all filtering of course lists

  • show/hide fields based on the drop-down list of choices

    I have a field from the drop-down list with three choices. Based on the selection, I need a specific text form field to appear and the others to stay hidden. (Or if it makes the code cleaner, the resulting field could be a drop-down list, too, with the selected choice.) I don't know Java well enough to extrapolate the code from the examples online and it fit my forms. I can provide an example of form. Thanks in advance for your help.

    There are ways to run this.  the easiest for you would be to add this script to the event (calculation of the Properties tab) to calculate the field that must be hidden.  Take notes, all "/ /" is some tips for you to understand the code.  You will need to put this script in all the areas you want to replicate the behavior, change the value depending on what you want to accomplish.  the word 'event' means myself to make you understand.

    If (this.getField("dropdown").value == 'put value here') {//replace "drop down" with the name of the drops}

    Event.Target.Display = display.visible;

    }

    else {}

    Event.Target.Display = display.hidden;

    }

    This works if you have a small amount of fields.  If you manage to have a large number of similar fields, let me know because there are other, faster ways.

  • Using the dependent drop-down list

    I created a form of dependent drop-down list in Acrobat X Pro using the example in the tutorial:

    http://acrobatusers.com/tutorials/js_list_combo_livecycle

    This code works very well, however, this tutorial only works if the options for dropdwon lists are complete words. Several words separated by spaces cannot be used because the main list options are used in the form of tables. In this tutorial, for example, the main list options are: Chassis, clutch, etc. (a Word). This technique does not work is for example, if the options in this list are 'Cylinder Ring', 'Insert', etc.

    Any ideas on how to implement function dropdow lists using multi-word options?

    Thank you.

    Just put in quotes the properties of the object. For example:

    var oAssemblyParts = {}

    "Châssis":]

    ["' - ', 'None'"].

    ['Rear Bracket', 205,95],

    [48,95, "Front bearing"]

    ],

    'Cylinder Ring':]

    ["' - ', 'None'"].

    etc.

Maybe you are looking for

  • macOS glitch Sierra

    I can't display critical Sierra macOS on the Mac App Store in white only. But I see comments for everything else. Difficulty?

  • How to reset the password of the bios of the compaq mini cq10? error CNU0090TDJ

    Please, I want to reset my cq10 bios compaq mini, but it asks the current password.

  • Lenovo Ideapad Y570 Touchpad 'Tapping' question

    Hello I just bought ideapad y570 and its been fine, but after months of use it my touchpad does not work as it was before. I noticed that when I tap on it, it does not select anything on my computer. It moves and everything but when I try to choose a

  • Move photos to HP Mediasmart

    I recently had to reinstall my OS (Vista) and my backed up the files on my HP desktop. My finished photos viewable in HP MediaSmart, but I can't do anything with them. I looked at the previous Forum replies on this issue but haven't seen a response t

  • Information on cable Sansa Clip

    I need to buy a new cable for my Clip and understand that it uses a standard USB 2.0 mini-B cable. When I did some research for this particular cable, I found cables 4-, 5-pin, and 8 pins. That one will work properly?