Searchable drop down menu? | Adobe Higher Education
Skip to main content
Level 2
November 5, 2009
Risolto

Searchable drop down menu?

  • November 5, 2009
  • 66 risposte
  • 37578 visualizzazioni

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.

Questo argomento è stato chiuso alle risposte.
Migliore risposta di 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 risposte

_Bruce_Robertson
Level 10
December 28, 2010

Hello Bibhu,

You would have got all the countries returned in your submit data because the data connection contained all the countries in my sample.  If you only wanted the values selected then there are a number of ways you can do this.  Possibly the easiest for a relatively static set of data like countries would be to put them in their own dataset.  You can do this manually in the XML Source tab or if your data is more dynamic then programmatically in the initialise event.  The example in the below link has the countries hard coded in the XML but there is code in the "Load Country List" button click event that loads the countries as well ... although this example just hard codes the countries this list could be held on the server.

https://acrobat.com/#d=xqToK-8CdJC01vfso*7DUQ

To explain the code.  The following line uses a predicate to select a subset of xml nodes from the countries list, in this case any country with a name that contains the characters in xfa.event.newText.

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

The following code loads up the listbox.  The country xml looks like <country id="AU" name="AUSTRALIA" /> so the resolveNodes method above will return a list of dataValue objects representing this xml, so they will name and id properties also of type dataValue, so you need to use the value property to return the current value.

   for (var i = 0; i < list.length; i++)
   {
       var country = list.item(i);
       Results.CountryList.addItem(country.name.value, country.index.toString());
   }

Regards

Bruce

Bibhu_Bikash_Na
Level 10
December 28, 2010

Hello Bruce,

I am not facing any problem in your xml. But when I am using some other xml file, some times the list boxes shows no value and sometimes the list box shows values but it's written only "Empty " over there. Could you please help me in writing the code if I give you the XML ??

Thanks.

Bibhu.

_Bruce_Robertson
Level 10
December 28, 2010

Hi Bibhu,

Can you post your xml here? if so I can have a look.

Bruce

Bibhu_Bikash_Na
Level 10
December 28, 2010

Hello Bruce,

Though my XML contains huge data I am giving it by trimming the XML.

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="dbo_ElectronicForm_UK.xsd" generated="2010-12-13T13:02:57">
<dbo_ElectronicForm_UK>
<ItemNumber>DG1061-6</ItemNumber>
<Title>Handtooled Mini Horizontal </Title>
<Price>9.99</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1062-3</ItemNumber>
<Title>Handtooled Mini Vertical </Title>
<Price>9.99</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1063-0</ItemNumber>
<Title>Handtooled Mini Verso </Title>
<Price>0</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1064-7</ItemNumber>
<Title>Back Pocket Mini Horizontal </Title>
<Price>9.99</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1065-4</ItemNumber>
<Title>Back Pocket Mini Vertical </Title>
<Price>9.99</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1066-1</ItemNumber>
<Title>Saddleworn Mini Horizontal </Title>
<Price>9.99</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1067-8</ItemNumber>
<Title>Saddleworn Mini Vertical </Title>
<Price>0</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1068-5</ItemNumber>
<Title>Saddleworn Mini Verso </Title>
<Price>0</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1069-2</ItemNumber>
<Title>Foiled Mini Horizontal </Title>
<Price>9.99</Price>
</dbo_ElectronicForm_UK>
<dbo_ElectronicForm_UK>
<ItemNumber>DG1070-8</ItemNumber>
<Title>Foiled Mini Vertical </Title>
<Price>0</Price>
</dbo_ElectronicForm_UK>
</dataroot>

Though I have many requirements , Intial requirement is the same as contry name with Title here, means there would be a textfield named search Title and when some one types some character in the Title then it will create a dropdown as it used to do in case of country example.

Thanks.

Bibhu.

Bibhu_Bikash_Na
Level 10
December 28, 2010

Hello Bruce,

Somehow after a lot of tweaking I have made this work. Will be back after sometime with mote doubts to bug you. Thanks

Bibhu.

_Bruce_Robertson
Level 10
December 28, 2010

Hi Bibhu,

Glad you got it sorted.  This is what I would have done;

list = xfa.resolveNodes('xfa.datasets.dataroot.dbo_ElectronicForm_UK.[At(Lower(Title),Lower("'+xfa.event.newText+'")) > 0]');
for (var i = 0; i < list.length; i++)
{
  var electronicFormUK = list.item(i);
  Results.CountryList.addItem(electronicFormUK.Title.value, electronicFormUK.index.toString());
}

Bruce

Bibhu_Bikash_Na
Level 10
December 28, 2010

Hello Bruce,

One more thing I would like to ask. I am trying to use xml schema along with xslt transformation to restrict the xml only to those field values that are filled rather than all the embeded data. But when I open the xml that's sent I could only see the column values say "ItemTitle" with no value in it. Could you please guide me into the same ?

Thanks.

Bibhu.

_Bruce_Robertson
Level 10
December 28, 2010

Hi Bibhu,

If this is something you are trying to do on the server side then it is very unlikely I can help.  Have you tried the method I suggested above, in the sample form

https://acrobat.com/#d=xqToK-8CdJC01vfso*7DUQ ?

Bruce

Bibhu_Bikash_Na
Level 10
December 28, 2010

Hello Bruce,

I have huge amount of data to be embeded. And all those data change from time to time. So I guess it's not a good idea to use hardcoded value. Is there any alternative ?

Thanks.

Bibhu.

_Bruce_Robertson
Level 10
December 28, 2010

Hello Bibhu,

I'm guessing your data is currently part of your data connection, maybe you can load this data in it's own dataset, similar to the "Load Country List" button click event code in my sample and then delete it from the data connection.  Alternatively you could load the alternative dataset using a webservice or maybe an OLEDB connection (though I have not done that).

There is also a preSubmit event which would allow you to script changes to the form data before it is submitted.

Bruce