• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

formatting text box depending on input from another text box

Community Beginner ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Hi

im creating a form in which i need to limit the input into a text box based on the value of another text box. for example if text box "wpds" has UB36 input into it, I then want text box "pass"  to only allow the input of "Root","Hot", "Fill" or "Cap".  But if text box "wpds" has UF49 input into it, i want text box "pass" to only allow the input of "Layer1" "Layer2" or "Layer3".  Any input into this will be greatly appreciated. thanks

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

You should use a drop-down field, then, and set its options based on the first of the first field (using a script).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

would you have an idea of what that script might look like? or know of a thread that speaks off it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Here's an article on exactly this topic:

https://acrobatusers.com/tutorials/js_list_combo_livecycle

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

the only question i have for doing a dropdown instead of a text box is do you call the value of that dropdown menu the same way you would for a textbox? this.getField("pass1").value or is there a different way for dropdown's? i have a bunch of caluculations in other text boxes that need the value of the text box in question.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

Yes, it's the same.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

is it possible to change the size of the arrow on the drop down box and is it also possible to change the alignment of the text in the dropdown?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2019 Jan 09, 2019

Copy link to clipboard

Copied

No, and no. You can add spaces or tabs (using a script) before the items, but that's about it.

Oh, and you can set the entire field as Right-To-Left if you want the text to be aligned to the right and the arrow to appear on the left.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

so would building those lists be kinda like nested if statements? would you able to add a layer to that? could you have one drop down which controlled another which  controlled another? in the example for your article the assembly dropdown controls the contents that are visble in the parts dropdown, would you be able to have the parts dropdown control a price dropdown that would have prices for like  OEM part and an aftermarket part?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

Yes, that's possible. I call it "cascading dropdowns" and have developed a (paid-for) tools that allows you to set it up very easily, based on a spreadsheet: Custom-made Adobe Scripts: Acrobat -- Create Cascading Dropdowns

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2019 Jan 10, 2019

Copy link to clipboard

Copied

Yes, it can be setup any way you want. And there can be multiple cascading dropdowns. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

so if i where to add a level to your example where would you put the code for the next list? im having a hard time trying to figure this out, if you could give me and example of how you would go about setting up the next level of lists it would be much appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

so in your example i noticed when making your lists you put  ["Dogs", "dogs"], is "Dogs" the item and "dogs" the export value?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

is this how you would nest the combo boxes?

var oAssemblyParts = {
                       Chasis: [
                                 "Rear Bracket": [ ["-","None"], ["1",205.95], ["2",185.95], ["3",44.95],["4",48.95]],
                                 "Front Bracket": [ ["-","None"], ["5",15.95], ["6",22.95], ["7",44.95],["8",32.95]],
                                 "Long Support":  [ ["-","None"], ["9",139.95], ["10",85.95], ["11",15.95], ["12",22.95]],
                                 "Front Bearing":[ ["-","None"], ["13",35.95], ["14",19.95], ["15",8.95],["16",17.95]]
                               
                               ],

                       Clutch: [
                                "Plate 1": [ ["-","None"], ["17",205.95], ["18",185.95], ["19",44.95],["20",48.95]],
                                "Plate 2": [ ["-","None"], ["21",15.95], ["22",22.95], ["23",44.95],["24",32.95]],
                                "Inside Shaft":  [ ["-","None"], ["25",139.95], ["26",85.95], ["27",15.95], ["28",22.95]],
                                "Outside Shaft":[ ["-","None"], ["29",35.95], ["30",19.95], ["31",8.95],["32",17.95]]
                               ],

                       Brake:  [
                                "Master Cylindar": [ ["-","None"], ["33",205.95], ["34",185.95], ["35",44.95],["36",48.95]],
                                "Slave Cylindar": [ ["-","None"], ["37",15.95], ["38",22.95], ["39",44.95],["40",32.95]],
                                "Pad":  [ ["-","None"], ["41",139.95], ["42",85.95], ["43",15.95], ["44",22.95]],
                                "High Presure line":[ ["-","None"], ["45",35.95], ["46",19.95], ["47",8.95],["48",17.95]]
                               ],

                       Coolant:[
                                "Pump": [ ["-","None"], ["49",205.95], ["50",185.95], ["51",44.95],["52",48.95]],
                                "Thermostat": [ ["-","None"], ["53",15.95], ["53",22.95], ["54",44.95],["55",32.95]],
                                "Coolant Line":  [ ["-","None"], ["56",139.95], ["57",85.95], ["58",15.95], ["59",22.95]],
                                "Reservoir":[ ["-","None"], ["60",35.95], ["61",19.95], ["62",8.95],["63",17.95]]
                               ]
                  };       

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2019 Jan 13, 2019

Copy link to clipboard

Copied

The answer is Yes, and nesting is the wrong word. They are cascading (interdependent) combo boxes. Cascading because selecting one leads to the next.

This object shows the selections and data for 3 levels all combined into one compound object. A better (more generic) way to do it for multiple levels is to create a separate object for each level, so they can be extended indefinitely. It's also easier to maintain.

// 1st Level

var oAssemblyParts = {  Chasis: {list:oChasisItems},Clutch: {list:oClutchItems},Brake: {list:oBrakeItems} };

                 };    

// 2nd Level

var oChasisItems = { "Rear Bracket":{list:oRearBracketTimes}, "Front Bracket": {list:oFrontBracketItems},...};

var oClutchItems = {"Plate 1":{list:oPlate1Items},...};

// 3rd Level

var oRearBracketTimes = {"-":{data:"None"}, "1":{data:205.95}, "2":{data:185.95}, "3":{data:44.95} };

Notice that each level clearly indicates either the next level of associated list items, and/or the data associated with the selection. This structure also has the advantage that you can include items in more than one list.

The event scripts on each drop down are exactly the same, except for the reference to the next dropdown.  The data here is formatted as a single number (i.e. the price of the final item), but it could be another object that contains more complex data. For example, the object member names could be the field names where the data is placed. This makes for very generic code.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2019 Jan 15, 2019

Copy link to clipboard

Copied

not sure if this is right but this is what i came up with, am i on the right track?

var oCountrySelection = {Canada: [ist:oCanWeldProcedures], "United States":

    };
                          
    var oCanWeldProcedures = {DB48:
      ,
                                LB20:
        ,
                                  LB32:
          ,
                                     LB6:

                                      LB70:
              ,
                                        LB75:
                ,
                                          LB77:
                  ,
                                            LB82:
                    ,
                                              LB88:
                      ,
                                                PS01:
                        ,
                                                  UB36:
                          ,
                                                    UB44:
                            ,
                                                      UB45:
                              ,
                                                        UB46:
                                ,
                                                          UB47:
                                  ,
                                                            UB73:
                                    ,
                                                              UB74:
                                      ,
                                                                UB75:
                                        ,
                                                                 };

var oUSAWeldProcedures = {DB48:

    ,
                              "END-UF-1":
      ,
                                LB20:
        ,
                                  LB32:
          ,
                                    LB6:
            ,
                                      LB70:
              ,
                                        LB75:
                ,
                                          LB77:
                  ,
                                            LB82:
                    ,
                                              LB88:
                      ,
                                                PS01:
                        ,
                                                  UB36:
                          ,
                                                    UB44:
                            ,
                                                      UB45:
                              ,
                                                        UB46:
                                ,
                                                          UB73:
                                  ,
                                                            UB74:
                                    ,
                                                              UB75:
                                      ,
                                                                };

var oPassDB48 = {Root:

    , Hot
      , Fill
        , Cap
          };
          var oPassEndUF1 = {1:
            , 2
              , 3
                };
                var oPassLB20 = {"All Passes":
                  };
                  var oPassLB32 = {Root:
                    , Remaining:
                      };
                      var oPassLB6 = {"All Passes":
                        };
                        var oPassLB70 = {"All Passes":
                          };

Var oPassDia1 = {["-", "None"], ["1/8", "1/8"], ["5/32", "5/32"]};    
Var oPassDia2 = {["-", "None"], ["3/32", "3/32"], ["1/8", "1/8"], ["5/32", "5/32"], ["3/16", "3/16"], ["7/32", "7/32"]};
Var oPassDia3 = {["-", "None"], ["3/32", "3/32"]};
Var oPassDia4 = {["-", "None"], ["1.1mm", "1.1mm"]};
Var oPassDia5 = {["-", "None"], ["3/32", "3/32"], ["1/8", "1/8"]};
Var oPassDia6 = {["-", "None"], ["3/32", "3/32"], ["1/8", "1/8"], ["5/32", "5/32"], ["3/16", "3/16"]};

function SetPartEntries()
{
 
   if(event.willCommit)
   {
    
      var cRowName = event.target.name.split(".").shift();

     
      var lst = oCountrySelection[event.value];
    
      if( (lst != null) && (lst.length > 0) )
         this.getField(cRowName + ".PassSelect").setItems(lst);
      else
      {
         this.getField(cRowName + ".PassSelect").clearItems();
      }

    
   }
}

function CANWeldProcedures()
{
 
   if(event.willCommit)
   {
    
      var cRowName = event.target.name.split(".").shift();

     
      var lst = oCanWeldProcedures[event.value];
    
      if( (lst != null) && (lst.length > 0) )
         this.getField(cRowName".pass").setItems(lst);
      else
      {
         this.getField(cRowName".pass").clearItems();
      }

    
   }
}

         
function  USAWeldProcedures()
{
 
   if(event.willCommit)
   {
    
      var cRowName = event.target.name.split(".").shift();

     
      var lst = oUSAWeldProcedures[event.value];
    
      if( (lst != null) && (lst.length > 0) )
         this.getField(cRowName".pass").setItems(lst);
      else
      {
         this.getField(cRowName".pass").clearItems();
      }

    
   }
}

function pass()
{
 
   if(event.willCommit)
   {
    
      var cRowName = event.target.name.split(".").shift();

     
      var lst = oPassDB48[event.value];
    
      if( (lst != null) && (lst.length > 0) )
         this.getField(cRowName".Dia").setItems(lst);
      else
      {
         this.getField(cRowName".Dia").clearItems();
      }

    
   }
}

function  pass2()
{
 
   if(event.willCommit)
   {
    
      var cRowName = event.target.name.split(".").shift();

     
      var lst = oPassEndUF1[event.value];
    
      if( (lst != null) && (lst.length > 0) )
         this.getField(cRowName".pass").setItems(lst);
      else
      {
         this.getField(cRowName".pass").clearItems();
      }

    
   }
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2019 Jan 15, 2019

Copy link to clipboard

Copied

unlike the methodology laid out in the article, the data objects in this strategy use sub-members to hold both the list and the data. For example, when selecting the next list to select from the "oCountrySelection" object, the "list" member needs to be referenced.

Like this:

var lst = oCountrySelection[event.value].list;

And if there were data associated with this item (to be set in other form fields), it would be referenced as

var data = oCountrySelection[event.value].data;

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 15, 2019 Jan 15, 2019

Copy link to clipboard

Copied

thanks for all the help, i tried using that method but couldnt get it to work. i ended up using the same method from the article and getting it to work for what i need. the only issue that im trying to get a single combo box to initiat the cascade of combo boxes for multiple rows. i change the "if(event.willcommit)" part of the code to  if(this.getField("Country").value == Canada || this.getField("Country").value == "United States") but that doesnt seem to work.  is there a way to make my multiple row cascade of combo boxes to start off of a single combo box?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2019 Jan 15, 2019

Copy link to clipboard

Copied

Any error message in the console?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2019 Jan 15, 2019

Copy link to clipboard

Copied

The way to debug this is to use the Console Window.

First, use it to check for any errors, as suggested by Bernd,

Then, insert "console.println()" statements in your code to display values of interest, such as "cRowName", to make sure your getting the correct field names.

Right off I can tell you that there are errors in the code you posted.

For example, in this code:

  this.getField(cRowName".pass").clearItems();

The row name is not being concatenated with the field name. It should be

  this.getField(cRowName + ".pass").clearItems();

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

unfortunatly im working with bluebeam revu and i dont think it has a console window. is there a ways that i would be able to call individual parts of each list to a combo box? at least if i could do that i could manually check each list.

Var oPassDia1 = {["-", "None"], ["1/8", "1/8"], ["5/32", "5/32"]};   

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

I'm pretty sure Bluebeam does have a console window. It's a standard part of any JavaScript environment. It might be listed in the documentation as "Interactive Mode" or something like that.

Regardless, you've got a pretty complicated script. I would suggest staring out with the simplest possible implementation to test each part of what is needed. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

I found the console, i put the entire code in and it gave me this

SyntaxError: missing ] after element list

0:var oCountrySelection = [Canada:

    ,

here is that section of code

var oCountrySelection = [Canada:

    ,

                      "United States":

    ];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

it doesnt matter what part of my list i enter it says the same thing

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines