Searchable drop down menu? | Community
Skip to main content
Level 2
November 5, 2009
Solved

Searchable drop down menu?

  • November 5, 2009
  • 66 replies
  • 37591 views

I have several drop down lists in a PDF I am creating. These drop down lists contain diagnoses to be used by physicians. With there being a LOT of diagnoses, it would be extremely convenient if I had a "search" function of some kind that could be utilized as the wording of the descriptions for the codes/diagnoses can vary: (Ex. "Rib Pain" or "Pain in Rib")

As of now, the only option is to select the first letter of the name they believe the diagnosis to have. Using this example, they would select the drop down menu and press "R" and the list would jump down to the beginning of the R's. But, if the name is actually "Pain in Rib", they would have to search through all the other diagnosis codes to locate it.

I believe a search function would be the most appropriate for something like this. But, I am having some trouble locating any info on coding for something of this nature. If there are any suggestions that could make this, (or something that accomplishes the same task), possible, I am all ears.

Thanks!

I included a pdf with the fragment with the drop down menus as well as a list of the diagnoses I have in them.

I appreciate any help or ideas. I've never been let down by the people here in these forums.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by tarekahf

I was able to use the Net.HTTP and SOAP object to access the same DMTI service, but it worked only on the console window:

var jData;

var prm =

{cVerb:"GET",

aHeaders: [{name: "Authorization", value:"authentication-token"}],

cURL: "https://app2.dmtispatialxxx.com/servicesxxx/rest/suggest?limit=60&includePostalCode=true&address=20%20crown%20ste",

oHandler: {

   response: function (msg, uri, e) {

    console.println("\nThis is the response method:");

    console.println("msg=" + msg);

    //for (var p in msg) {

    //  console.println("p=" + p);

    //  console.println("msg[p]=" + msg[p]);

    //}

    var data = SOAP.stringFromStream(msg);

    jData = JSON.parse(data);

    console.println("Length of json data: " + jData.length);

    console.println("data=" + data);

    console.println("e=" + e);

   }

}

};

Net.HTTP.request(prm);

Response from the console window:

This is the response method:

msg=[object Stream]

Length of json data: 5

data=[{"matchCount":1,"suggestion":"20 CROWN STEEL DR MARKHAM ON L3R9X9","aliasSuggest":null},{"matchCount":1,"suggestion":"20 CROWN ST QUINTE WEST ON K8V1N6","aliasSuggest":null},{"matchCount":1,"suggestion":"20 CROWN ST ST. CATHARINES ON L2M3L3","aliasSuggest":null},{"matchCount":1,"suggestion":"20 CROWN ST THUNDER BAY ON P7B3J6","aliasSuggest":null},{"matchCount":1,"suggestion":"20 RUE CROWN DANVILLE QC J0A1A0","aliasSuggest":null}]

e=undefined

Unfortunately, the above method didn't work from a the click event of a button (in Adobe LiveCycle form). I got this error:

NotAllowedError: Security settings prevent access to this property or method.

Net.HTTP.request:19:XFA:form1[0]:subform[2]:Button4[0]:click

It looks like the only option now is to develop a wrapper component that can be invoked using the simple URL and to include the authentication token in the query parameters. Also, there is another problem... I have to get authentication code every time it is expired. Currently, there is Java code responsible for this part.

Question:

Why not develop a simple javascript program that can be invoked using HTML or jsp code, and return the result by clearing the output and just dump the result from the xhr response object? While I can develop the server component, but it seems a lot more easier to develop such component using only HTML and javascript. But, I am not  sure if it can be done, I just think it is possible.

66 replies

_Bruce_Robertson
Level 10
July 12, 2011

Hi,

I put an updated version of this sample in Adobe Designer Cookbooks, http://cookbooks.adobe.com/post_Drop_Down_List_Control_with_auto_complete__Searcha-18402.html.

Regards

Bruce

Level 2
July 12, 2011

Great information!  Thank you for responding to me and putting together the recipe.  This really adds value to my form.

kidneyfailure
March 16, 2012

i want to in http://www.stemcellscn.com upload pdf to download for people.

tarekahf
Level 8
April 26, 2016

The link provided is not working.

Tarek

_Bruce_Robertson
Level 10
April 26, 2016

Hi Tarek,

Adobe took the cookbooks down, but you can find everything I had up there on my blog, http://adobelivecycledesignercookbookbybr001.blogspot.com.au/2014/02/updated-drop-down-list-control-with.html

Bruce

tarekahf
Level 8
April 27, 2016

Thanks a lot BR001_ACP !

I need some help to customize the parts developed for the Drop-Down List with search feature.

I am trying to develop a reusable fragment to be applied for tens of drop-down list fields (DDL).

Basically, I will pass the DDL field to the fragment, and the modified fragment (the parts you developed) will copy the items from the DDL to the List Box inside the fragment, in addition to using the fragment as an overlay on top of the passed DDL parameter field. Finally, when a value is selected, it will be passed back to the original DDL field.

For now, (see code below) I want the most efficient way to copy the items "copyItems()" from the DDL field "theDDLField" to the search result list box "theResultsField".

See the developed fragment here.

Also, see snapshots to clarify.

Appreciate your help.

var theDDLField=null;

var theSearchField=null;

var theResultsField=null;

function clearVars() {

  theDDLField=null;

  theSearchField=null;

  theResultsField=null;

}

function setMatchFirstCharacters(prmMatch) {

  this.MatchFirstCharacters.value = prmMatch;

}

function setVars(prmField) {

  theDDLField = prmField;

  theSearchField = Background.Search;

  theResultsField=Results.ListBox;

}

function copyItems() {

  //copy items from the DDL Field (theDDLField) to the List Box (theResultsField)

}

function show(prmDDLField) {

  setVars(prmDDLField);

  this.presence  = "";

  this.relevant = "-print";

  this.x = prmDDLField.x;

  this.y = prmDDLField.y;

  theSearchField.w = prmDDLField.w;

  theSearchField.caption.reserve = prmDDLField.caption.reserve;

  theDDLField.presence = "hidden";

  copyItems();

  xfa.host.setFocus(theSearchField);

}

function hide() {

  this.presence = "hidden";

  if (theDDLField) {

  theDDLField.presence = "";

  theDDLField.execEvent("exit");

  } else {

  app.alert("Error: theDDLField is null while in hide().");

  }

  clearVars();

}

_Bruce_Robertson
Level 10
April 28, 2016

Hi Tarek,

You can use something like;

function copyItems(dropDownList, listBox) {

    var itemList = [];

    for (var i = 0; i < dropDownList.length; i++) {

        itemList.push(dropDownList.getDisplayItem(i));

        itemList.push(dropDownList.getSaveItem(i));

    }

    listBox.setItems(itemList.join(),2)

}

Then call it with;

copyItems(theDDLField,theResultsField);

Or if you don't have a bound item, just

function copyItems(dropDownList, listBox) {

    var itemList = [];

    for (var i = 0; i < dropDownList.length; i++) {

        itemList.push(dropDownList.getDisplayItem(i));

    }

    listBox.setItems(itemList.join())

}

That is without the getSaveItem and without the ",2" on the join.

Another possible complication is if either your display item or the bound item could have a comma character in it then you will need to escape it, as the setItems takes a comma separated list, so;

        itemList.push(dropDownList.getDisplayItem(i)).replace(/,/g, "\\,");

Regards

Bruce

tarekahf
Level 8
April 28, 2016

Thanks a lot BR001_ACP​.

I am now nearly done with the fragment, still facing some UI and usability issues.

Appreciate it if you could follow me to the related forum post here:

Using fragment to implement Drop-Down List Field with search / auto populate

Tarek

Moonraker046
Level 2
September 7, 2017

Is there any way to combinate this auto populated drop with a web service (REST or SOAP)?

Could be very useful for a user search integration within a LDAP directory.

_Bruce_Robertson
Level 10
September 12, 2017

Hi,

I have not had a need to try this, though you see this more and more.  Do you have a public web service available that I integrate my "searchable drop down" control with?

Regards

Bruce