Expand my Community achievements bar.

SOLVED

Searchable drop down menu?

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Level 8

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%...",

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.

View solution in original post

66 Replies

Avatar

Level 10

Hi,

I've done something similar using a textbox and a listbox, which I hide when the textbox is empty and populate with matching entries when it is full.

Might be a starting point for you, attached is my demo.

Bruce

Avatar

Level 1

I too think your best option would be a text field and list box as recommended. I probably can't give you a better example than what was already given.

Avatar

Level 7

Hi jrhea1984,

Is it possible to post the Problem + Diagnosis menus PDF sample again  without fragment?

It is very intersting the way you have done the searchable Drop down menu even with first letter!

From the Fragment I can not view your Scripts..

There is any way to help me how you did is?

Thanks

Avatar

Level 9

Hello Bruce ,

I liked your script. Though it worked for me , I could not get a complete hold of it. I mean how does it perform the action required for ? One more thing I have several connected Dropdowns, if some one selects a name from a drop down (as you select country here) then all the data associated with it in all the drop downs should be auto populated once its selected. I want to use MySQL DB here. I know I have to write some select/update statements here . But I am a bit confused, how to implement it , Would you please guide me in the same ?

Thanks.

Bibhu.

Avatar

Level 10

Hi Bibhu,

There's some code in the change event of the Search textbox that each time a character is entered (or changed) just matches all the values in the its list and populates a listbox with the matching values.

I can't help with you othe question, I've used a webservice for this sort of thing but never tried a direct connection.

Regards

Bruce

Avatar

Level 9

Hello Bruce,

I have one problem with your form. When I preview it in the LiveCycle Designer , then it works fine. But If I open it in the Acrobat then , it's not working. I man the list box is not showing the related values. I am confused what's the problem. My product version : LiveCycle Designer 8.2 , Acrobat - 9 Pro.

Thanks.

Bibhu.

Avatar

Level 10

Hi Bibhu,

When using Acrobat you will have to manually import the countries.xml datafile

Bruce

Avatar

Level 9

Hello Bruce,

Thanks. It worked. But I have few doubts regarding this.

- Do we need to place the XML files in the same folder as with the PDF ? I mean suppose we are developing a form which will be used by users. But we want that the administrator/form developer have the access to the XML files. When the user just opens the form,there will be no need to embed the data. In a nutshell the user will not be aware of what's happening at the back-end side ?

- Can we import the data in csv format ? If yes, how ?

- Can we export the data in csv format or it's only possible in xml format ?

I need your guidance on the above points.

Thanks.

Bibhu.

Avatar

Level 8

Hi,

When working with XFA you need to forget CSV for good! XML must be your

friend.

Tarek.

Avatar

Level 10

Hi Bibhu,

It sounds like you want one of Adobe's Server side products, maybe LiveCycle Forms, something to take the form template and some xml and render a PDF form. I don't know much about server side processing as I have never worked with any LiveCycle product except Designer. I think the server products do support XSLT so you could convert the csv file to the xml format needed by your form.

Sorry can't really help

Bruce

Avatar

Level 9

Hello Bruce,

Your example works fine. But there is a problem. It's not taking the space. For example :

There are 3 choices in the dropdown.

Say : abc

         ABC

         Abc 123

When I type 'a' then it lists all the choices without any problem. The moment I type 'abc' and hit the space bar all choices vanishes. Could you please tell how to include this functionality ? So that when the user hits the space bar after typing few characters those corresponding choices which has a space inbetween must be displayed?

Thanks.

Bibhu.

Avatar

Level 10

Hi Bibhu,

I'm not sure I understand, there are a number of countries with spaces in their names New Zealand and New Caledonia for example.  They seem to work as I would expect and as I think you are discribing.

Bruce

Avatar

Level 9

Hello Bruce,

What I was trying to say is : If you type New then both the countries New Zealand and New Caledonia are displayed. The moment you hit the space bar after typing the New then the dropdown suggest box goes blank. I want if you type some letter and after that we hit the space bar all those names containing that letter should be displayed , like that of a FaceBook/ Google search.

Thanks.

Bibhu.

Avatar

Level 10

Hi Bibhu,

I am not seeing this behavior, if I type the space after "New" then the two countries stay in the list. I have tested this code in versions of Reader 7.0.9 to X so I'm not sure what to suggest. What version are you using.

Bruce

Avatar

Level 9

Hello Bruce,

I am using LiveCycle ES 8.2.x and Acrobat 9 Pro and Acrobat reader.

Thanks.

Bibhu.

Avatar

Level 9

Hello Bruce,

There is a problem. The search results are only shown by the starting letter.

For Example : There are 3 Dropdowns.

                       Chistmas

                       Happy Christmas.

                       Happy Chrismas to you all.

If I type Christmas then it should show all the 3 entries. But it's showing only the starting Christmas. (This is only for the example purpose, the same situation is applicable to the Countries as well.)

Thanks.

Bibhu.

Avatar

Level 10

Hi Bibhu,

You could change the sample to work in this way by replacing the line populating the list in the Search text fields change event from

list = xfa.resolveNodes('$record.country.[Lower(Left(name,' + (xfa.event.newText.length) + ')) == "' + xfa.event.newText.toLowerCase() + '"]');

to

list = xfa.resolveNodes('$record.country.[At(Lower(name),Lower("'+xfa.event.newText+'")) > 0]');

Bruce

Avatar

Level 9

Hello Bruce,

It worked fine. But I have one problem again. After selecting a country from the dropdown when I submitted it through XML instead of getting only the country I have selected I get all those values that we are embeding in the form. Is there a way that we will get only the selected value as XML so that we can update our DB ? Otherwise it's not possible to update the DB after some selections has been made.

Thanks.

Bibhu.

Avatar

Level 9

Hello Bruce,

I tried to use another XML data other data country data. But The list box is showing empty.Could you please tell why ? And do you mind explaining the following codes that you have written ?

list = xfa.resolveNodes('$record.country.[At(Lower(name),Lower("'+xfa.event. newText+'")) > 0]');
    for (var i = 0; i < list.length; i++)
    {
        var country = list.item(i);
        Results.CountryList.addItem(country.name.value, country.index.toString());
    }

Here what does the variable "country" stand for ? Is it for the record source or just a variable, what are its functionalities?

What's meant by country.name.value ? You have a field name, that's why it's name or something else?

Thanks.

Bibhu.