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

Searchable drop down menu?

  • November 5, 2009
  • 66 replies
  • 37509 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
New Participant
September 22, 2017

Hi,

Getting an XML response would mean changing url bit from

    https://maps.googleapis.com/maps/api/place/autocomplete/json

to

    https://maps.googleapis.com/maps/api/place/autocomplete/xml

And then using the usual resolveNode methods;

if (googlePlacesResult !== "") { // probably not a trusted document yet

  var AutocompletionResponse = XMLData.parse( googlePlacesResult, true )

  if (AutocompletionResponse.status.value === "OK") {

   var predictions = AutocompletionResponse.resolveNodes("prediction[*]")

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

    var prediction = predictions.item(i);

    list.push([prediction.resolveNode("description").value.replace(/,/g, "\\,"), prediction.resolveNode("place_id").value]);

   }

  }

}

Then I guess you would have to make similar changes to the listbox click event

Bruce

Moonraker046
New Participant
September 21, 2017

Thank you very much BR001​ for the very helpful example.

Would it be possible to change the response format of the Google Places API to XML and parse the XML response into the XFA form?

tarekahf
New Participant
September 16, 2017

BR001​ Thank you so much! We have migrated most of our forms from Adobe LiveCycle PDF to HTML5, and implemented autocomplete feature for address lookup.

The other day I heard some business users asking for this feature (autocomplete) to be implemented on some legacy PDF forms. I think your sample will be of a great help.

Thank you!

Tarek

_Bruce_Robertson
New Participant
September 16, 2017

Hi,

Here is a sample using the Google Places web service, seem to work ok once you do the "trust document" thing on the yellow message bar that is displayed at the top of the form.

https://sites.google.com/site/livecycledesignercookbooks/home/GooglePlaces.pdf?attredirects=0&d=1

You will need to get a Google Places API key which you can get at Get a key for Google Places API Web Service  |  Google Places API Web Service  |  Google Developers

Bruce

_Bruce_Robertson
New Participant
September 13, 2017

This webserive does not seem to offer a partial match search, I assume you want people to be able to type something like "new" and get all the countries that contain "new" in their name? 

Still I can see this being useful, I might try the google places API, Google Places API  |  Google Developers , and see if I can get that to work, but this is a REST service not a SOAP one.

Will let you know,

Bruce

Moonraker046
New Participant
September 12, 2017

Hi Bruce,

I would suggest this web service http://www.webservicex.net/country.asmx?WSDL  (Download the XML, save it as *.wsdl file and create a new data connection within Designer with the saved *.wsdl).

The web service handles over a XML based list of all countries.

Regards
Moonraker

_Bruce_Robertson
New Participant
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

Moonraker046
New Participant
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.

tarekahf
New Participant
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

_Bruce_Robertson
New Participant
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