try to fill in a number field with the help of a drop-down list box control and a text box

That's what I work with so far.  The lines of code are quite simple, but (as I expand this to its full size of accounting for all combinations of variables) the result field seems suffocating and will not auto-update to change the variables in the form. Var v comes from a drop down menu, var n is a numeric field.

var v = this.getField("TextOptions").value;

var n = this.getField("Number").value;

If (v == "TextOptionA") if (n == '1') event.value = "2";

else if (v == "TextOptionA") if (n == '2') event.value = "3";

else if (v == "TextOptionA") if (n == '3') event.value = "3";

else if (v == "TextOptionA") if (n == '4') event.value = "4";

else if (v == "TextOptionA") if (n == '5') event.value = "4";

else if (v == "TextOptionB") if (n == '1') event.value = "0";

else if (v == "TextOptionB") if (n == '2') event.value = "0";

else if (v == "TextOptionB") if (n == '3') event.value = "1";

else if (v == "TextOptionB") if (n == '4') event.value = "1";

else if (v == "TextOptionB") if (n == '5') event.value = "1";

else if (v == "TextOptionC") if (n == '1') event.value = "2";

else if (v == "TextOptionC") if (n == '2') event.value = "3";

else if (v == "TextOptionC") if (n == '3') event.value = "3";

else if (v == "TextOptionC") if (n == '4') event.value = "4";

else if (v == "TextOptionC") if (n == '5') event.value = "4";

else event.value = "";

In addition, TextOptionA, C, E, G and I will produce the event.value even, given the same variable n.  The same is true with TextOptionB, D, F and H.  Is it possible to compress the "TextOptionX" s that will produce the same event.value gave a value of n in one line?  Something along these lines (I know its bad, but it's the idea):

var v = this.getField("TextOptions").value;

var n = this.getField("Number").value;

If (v == 'TextOptionA' or 'TextOptionC') if (n == '1') event.value = "2";

else if (v == 'TextOptionA' or 'TextOptionC' or 'TextOptionE') if (n == '2') event.value = "3";

else if (v == 'TextOptionA' or 'TextOptionC' or 'TextOptionE') if (n == '3') event.value = "3";

else if (v == 'TextOptionA' or 'TextOptionC' or 'TextOptionE') if (n == '4') event.value = "4";

else if (v == 'TextOptionA' or 'TextOptionC' or 'TextOptionE') if (n == '5') event.value = "4";

else if (v == 'TextOptionB' or 'TextOptionD' or 'TextOptionF') if (n == '1') event.value = "0";

else if (v == 'TextOptionB' or 'TextOptionD' or 'TextOptionF') if (n == '2') event.value = "0";

else if (v == 'TextOptionB' or 'TextOptionD' or 'TextOptionF') if (n == '3') event.value = "1";

else if (v == 'TextOptionB' or 'TextOptionD' or 'TextOptionF') if (n == '4') event.value = "1";

else if (v == 'TextOptionB' or 'TextOptionD' or 'TextOptionF') if (n == '5') event.value = "1";

else event.value = "";

Something like that could be reduced to about 40 220 + lines of code.  Please help us on a mannequin of javascript.

For the first part of the code, the problem might be that the value of the 'Number' field is a number, not a string (that you assume in your code).

To solve that you can access the field valueAsString instead of the value property property.

For the second part of the operator OR in JS code is ' | ', would therefore be the first if condition:

If (v == "TextOptionA" | v == "TextOptionC")

Note that the comparison of v must appear in both parts of the if statement, in its entirety.

Tags: Acrobat

Similar Questions

  • Populate drop-down list with the results of several drop-down lists

    Hi, I am creating a form where the results of two drop-down lists then would fill another drop-down list. I'm not new to javascript, but I'm new to using it in Acrobat, so while I found some answers to this: Drop-down list fill in multiple fields of text. I don't know where to implement this, if it is still the right thing, I'm looking for pipes for

    Oh and I use Acrobat Pro DC. Any help would be much appreciated!

    OK, you can create a function at the level of the document that is called in the Validate event of each of the two first drop down menus, something like:

    Function in JavaScript to the document level

    function updateDropdown() {}

    Get references to the drop-down menus of entry

    var F1 = getField ("DropdownList1");

    var F2 = getField ("DropdownList2");

    Refer to the output drop-down list

    F3 var = getField ("DropdownList3");

    Get the values of input field, as strings

    var s1 = event.target = f1? Event.value: f1.valueAsString;

    var s2 = event.target = f2? Event.value: f2.valueAsString;

    Fill the drop-down list of output with the elements, or deselect it if either input dropdown is 'empty' (single topic area)

    If (s1 = "" |) s2 === " ") {

    F3.clearItems ();

    } else {}

    F3.setItems (["", s1, s2]);

    }

    }

    In the two first downs Validate event, call this function like this:

    updateDropdown();

    You can of course name the function you want. More information about the properties and the methods used in the code are available in the Acrobat JavaScript documentation.

  • Make a field of text/hide according to the results of a drop-down list box

    Hello

    I wonder if someone could help me with this. I want to show/hide some text boxes in my form according to the choice made by the person filling in. For example, there is a dropdown list containing a selection of numbers 1-4. If 1 was selected, the text boxes below 1 would be visible and obligatory, if the 2 have been chosen, 2 text boxes below would be visible and required etc...

    I'm new to FormCalc (only started using it this morning), so simple a possible explanation would be fantastic.

    Thanks for reading!

    Of course, you can have javascript and formcalc in the form. Not only the two in the same field, same event; D

    Okey, let's try some things:

    (1) check if the "binding" from the drop-down list is the same as the values that you choose. In the script you are referring to the bound values.

    (2) other names for the Textfields would be better, because it is more difficult to refer to "Textfield1 [1]" then to for example: 'New '. I was just to lazy to give them names. (If it's on another page or subform, you refer to the fields correctly: as MyForm.FirstSubform.FirstTextfield... this name lies in the specific script field.)

    (3) check your script once more... want to make invisible mandatory fields?

    (4) check if your form is dynamic. (If it isn't you will not see the changes...)

    You should probably do it in small steps, such as:

    (1) first of all, you refer to areas such as:

    This.rawValue = Firstfield.rawValue;

    If the changed value fields got you its name and to be sure that the event you put is the right one.

    (2) try the different parts of the script and look at how it works. Problems can be more easily found and then

  • Can anyone help please if a drop-down list box with this dpdCategory.Items.Insert (0, "user")?

    can someone please help if a drop-down list box with this dpdCategory.Items.Insert (0, "user"); If I choose the user then after clicking the button, it will redirect to this page & also, others using if else statement

    Please ask this question in one of the Windows Apps development forums:

    http://social.msdn.Microsoft.com/forums/en-us/category/windowsapps

  • Forms - selection drop-down list box makes other fields appear

    I am building a form in InDesign that I export to PDF format with several fields (text, drop-down list, radio, checkboxes). Some fields are defined to trigger the visibility of other fields and that works very well. What I want to do and what I can barely reach, is to have a selection for a combo box, make 3 other visible fields. I'm just a beginner when it comes to buttons in InDesign and the forms of the suggestions would be appreciated.

    If it is easier to achieve in Acrobat I try too.

    In case someone sees this in the future, I found a site with a solution which works perfectly and it's so EASY!

    How can I make a visible field on a selection in the drop-down list box? (PDF Forms)

  • How to use the drop-down list box to fill in a text box

    I'm a beginner when it comes to Java Script.  I have seen a lot of different discussions, look at a lot of articles "helping" Acrobat 9 and Java Script, but only to be left confused and dazed.  I hope someone can tell me how to write a script that fills a text box that sits on my form with the value of exports of the selection in the combo box...

    Thank you

    If you want that the read-only text box, simply set with the following custom calculate script:

    Set this field to the value of the drop-down list box

    Event.Value = getField("combo1").value;

    but replace "combo1' with the actual name of the combo box field.

    If you want something else, post again with more information.

  • Show drop-down list field hide selection in another drop-down list box

    Hello I need to create two drop-down fields on a dynamic PDF in LiveCycle. The first field contains three choices. When a user selects an item in the drop-down list first I would like to a new field of drop-down list has been shown. For each item in the first drop-down list appears a new field drop-down list with unique values. If the user chooses blue drop-down list of blue shades indicate in this menu drop-down will be various shades of blue to choose for. If the Red is chosen, Shades of Red dropdown with appearance and if yellow is displayed the same occurs. Also if the user must go back and change their selection in the first drop-down list, they can do the same. Any suggestions?

    Thank you in advance.

    There are 2 ways you could do this. The first is just to have the 3 drop-down lists for the second box to separate and do them all hidden. The output of the first dropdown event would then have the code that would make it the second box become visible, something like (in formcalc):

    If ($ == 1) then

    dropdownRed.presence = "visible".

    dropdownBlue.presence = "hidden".

    dropdownYellow.presence = "hidden".

    ElseIf ($ == 2) then

    dropdownRed.presence = "hidden".

    dropdownBlue.presence = "visible".

    dropdownYellow.presence = "hidden".

    ElseIf ($ == 3) then

    dropdownRed.presence = "hidden".

    dropdownBlue.presence = "hidden".

    dropdownYellow.presence = "visible".

    endif

    The other option is just to have a dropdown that dynamically changes its options based on the results of the first box. So in the second box preOpen event you might have something like (in formcalc):

    If (dropdown1 == 1) then

    $. clearItems()

    $.setItems ("light red, dark red")

    ElseIf (dropdown1 == 2) then

    $. clearItems()

    $.setItems ("sky blue, dark blue")

    ElseIf (dropdown1 == 3) then

    $. clearItems()

    $.setItems ("light yellow, dark yellow")

    endif

  • Download the news of a drop-down list for a field of text box

    Its that simple! That's all I need to know! The code to add to the information in a drop-down list (_cb) to a text field. I need to know wear put on the script IE in the action on the _cb layer. Your all!

    on the timeline that contains your combobox with instance name _cb that you can use:

  • Change the number of items in the drop-down list box when running

    I'm trying to change the number of items in one of my boxes of comobo.

    I have been through the help and this forum and have the values to within the drop-down list box change very well, but in a scenario, I want to go to three options for 2. And according to other choices to 3.

    I guess I have to use a property node but I can't understand that one.

    You can use the method to reset to zero (using an invoke node) before setting the [Strings] (after setting the value by default an empty array) or create an Xcontrol (you can see examples of LabVIEW for xcontrol).

    Ben64

  • I also have a .csv file with the name of a jpeg file in a column and a text description of each jpeg format in a second column. Is it possible to automatically insert a jpeg (picture) and its corresponding text, each pair on one page, in an Indesign docum

    I also have a .csv file with the name of a jpeg file in a column and a text description of each jpeg format in a second column. Is it possible to automatically insert a jpeg (picture) and its corresponding text, each pair on one page, in an Indesign document?

    Read about to merge data in the help files.

  • Command to refresh a calculated field when you select an option from the drop-down list box

    When my form user selects an option in a drop-down list box, the value in the field (in this case, Total) I would like to update, but it isn't.

    A radio button option box makes the Total-development field to automatic update when the user clicks on the radio button. But the drop-down list box is not updated Total (without clicking away from the field). I would like to add a command in the Combo Box to refresh the Total field when you selected the option to drop-down list box.

    Someone at - it a code (Javascript?) to get there.

    Thank you very much.

    You don't need a script, simply select the 'Value selected to validate immediately' checkbox on the Options tab of the dialog list box drop-down list box field properties.

  • Fill other fields based on a drop-down list box

    Hello

    I am completely new to LiveCycle and just starting to teach me how to use it.

    I want to speed up the filling of a purchase order by bringing them to fill based essentially on what is put in other areas.

    For example, I would like to than our usual suppliers to be included in a drop of water to the bottom of the box (I know not how, at least) and then have the address fields automatically filled.

    I know that I can do this using javascript, but it is rather annoying because I don't want to sit here put 276 suppliers in my script. In addition, I don't want to have to edit the script whenever we want to add a new provider.

    Is it possible to create a form that made it and can pull info on another file or database? Also, I would make it pretty fool-proof when it comes to adding new suppliers.

    Thank you

    Darryl

    The way to proceed is to hang on to the top of the drop-down list for a service web and that the web service returns a list of providers (in load of the form). Once the user selects a supplier a second web service would draw information and fill in the appropriate fields.  This technique is easier to configure on the client machines (as all the information is contained in the form). You will need to get another piece of software called LiveCycle Reader Extensions Server to allow the form make calls from web service of the player (assuming that the reader is used).

    The form can connect to a database directly, but this solution has drawbacks as well. You need to configure a dataconnection on each machine as the machine must be on the same network as the DB. It will work on Windows machines. You also punctuated by player to allow DB with Reader connections.

    Hope that helps

    Paul

  • Help with the drop-down list boxes

    Hello.  I am working on a form that contains three drop-down lists that have different names.  All three have the same point selections, but I want that each of the three to automatically fill in its respective field (it is essentially a price sheet where up to three elements may be selected and you'd see every price indicated in front of it).  I got concerning depression the 1st drop to fill its field using the script "setvalues.

    However, when I try to create the following scripts for two other menus, it seems that I finally, create all three drop-down lists that all fill in the very field that corresponds with the latest script, that I added, instead of the respective field. To clarify, after 1 was created, it works normally.  When I create a second script for the 2nd menu drop-down & price field, both drop-down lists only affect the 2nd price field.

    I assured the fields have different names, and these names are specified in each script.  I do not understand why acrobat would allow, when the script specifies the field that I entered.  It is essentially in a field that isn't in the script.  Of course, I am a novice, so any idea how works this process is very appreciated!

    Thanks for your reply, George!   I really love it!  What I was doing wrong placed the code in the javascript Document, so it was essentially apply the script all dropdowns.  What I did instead was delete and go in each drop-down list individual and added the script as the custom format script.  Just in case someone else did the same thing, here's the script that I use [details omitted to save space...]

    Put all vorkriegsbevölkerung data in a single data structure

    var LaborCode = {SelectCode: {cost: ' '},}

    XYZ {cost: "123.45"},

    };

    function SetFieldValues (cLaborCode)

    {

    this.getField("LaborPrice").value = LaborCode [cLaborCode] .cost

    }

    Thank you!!

  • fill a list based on a value from the drop-down list box

    Well, I know a way around it but its quite long with what I know. I worked on a better solution for a day now. So maybe (or likely) someone knows better. I'm trying to fill a drop drop down based on a user selection figure in a list of check boxes. I know I could create several drop-down lists and hide away them until the user changes the value of binding. But the dropdowns would consume a lot of space in my form design in liveCycle. So is there another way or I'm stuck he made a long journey. I also need to assign values to these elements, since they change because the values are used as item numbers later that fill a text/number field later in form as a list of materials.

    Tell me if I'm wrong, please (I'm new to all this)

    in the box in the click event

    If (this.) RawValue == 1)

    {

    dropDownList1.addItem ("item # 1", "value1111");

    dropDownList1.addItem ("item # 2", "value2222");

    }

    on the other

    {

    dropDownList1.rawValue = "null";

    }

    I'm sure that null is not good and I don't know that I have to set the drop-down menu to clear items on preOpen. Or maybe not. And there is a way to add items without the addition of a new right of the line? I'm on the right track?

    Hello

    Rather than having the script in each of the boxes, you can have the script in the event preOpen the drop-down list that leans on the boxes.

    I downloaded an example here: https://acrobat.com/#d=VwREjsMgvqXpVqPu54kSNw

    Take a look at the preOpen the dropdown event.

    // clear the dropdown displayed value and items
    this.rawValue = null;
    this.clearItems(); 
    
    // repopulate the items based on the checkboxes
    if(fruit.rawValue == 1)
    {
         this.addItem("Apples", "fruit_001");
         this.addItem("Pears", "fruit_002");
         this.addItem("Oranges", "fruit_003");
         this.addItem("Bananas", "fruit_004");
         this.addItem("Grapes", "fruit_005");
    }
    
    if(cars.rawValue == 1)
    {
         this.addItem("Volvo", "car_001");
         this.addItem("Ford", "car_002");
         this.addItem("Opel", "car_003");
         this.addItem("Toyota", "car_004");
         this.addItem("Nissan", "car_005");
    }
    
    if(counties.rawValue == 1)
    {
         this.addItem("Co. Tipperary", "county_001");
         this.addItem("Co. Cork", "county_002");
         this.addItem("Co. Dublin", "county_003");
         this.addItem("Co. Clare", "county_004");
         this.addItem("Co. Kerry", "county_005");
    }
    

    Hope that helps,

    Niall

  • Change the caption of a drop-down list field

    Hi all

    I'm changing the legend of some field drop-down under certain conditions. The following is written on some other field drop-down list:

    If (this.rawValue == 'Ad Hoc payments')

    {    

    xfa.resolveNode ("form. PaymentDetails.ddlInvoiceFrequency.caption #text ") .rawValue group"TEST CAPTION";

    }

    But it seems to not work.

    Any help would be much appreciated.

    Thank you

    Vijay.

    Try with this:

    delete the caption in the palette of the subject field and type this in the case of change:

    If (xfa.event.newText is "Ad Hoc payments") this.caption.value.text.value = "TEST CAPTION";

Maybe you are looking for

  • App for screen need more dark

    I do a lot of ebook reading on my Atrix overnight and in other low light situations. I need darken the screen even more than what allows the Atrix. Is there a good app that I can use? I tried to install the filter for the screen, but it could not ins

  • Pavilion m900y: Cpu

    Hello Tech Guru... I would like to upgrade my CPU... I have a processor 9750 Quad-core... AMD-Phenam... I can get an Intel Core i-7 - 5820 K installed by a reputable dealer, or is this not possible. I'm looking for more speed... and I don't do much i

  • Bar moves (up) to scroll by itself under Vista Home Premium 64-bit

    When you try to scroll a list (e.g. uninstall programs), the scroll bar moves by itself at the top on the list of programs; It also moves upward trying to decrease the volume; during the installation of a program, and then by selecting English as def

  • problems with readyboost

    I have to sdhc targets, a 4 GB and the other 8, I have problems to run readyboost with the last. He preferred me to choose to use it, but then I went again to see if it works and it's as if I'd never before.

  • SRA 4600 Web Application Firewall blocks access to the Portal login page.

    We have a 8.0.0.1 - 16 4600 running and run the Web Application Firewall.  We had a few reports of users home that our portal page was not available, only tried IE, but everything went well here.  Today we had an internal machine with the same questi