These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

LCD JavaScript - Trouble with the Change event.

StevenD
Registered: Oct 6 2006
Posts: 368

So far I am using the Change event for a dropdown field. In the dropdown field I have it set in the Binding tab to use the item values. I would like to use these value instead of the actual text that shows in the dropdown field. I cannot get it to work.

What is happening is this. When viewed in Preview the dropdown is blank. When i choose item 1 (only two item so far) nothing happens. When I choose item 2 instead of the fields being populated with data associated with item 2 they are populated with the data associated with item 1.

What am I doing wrong? Can anyone help me solve this? Can anyone give me pointers on how to work with this type of value?

Here is the script I am working with.

var choice1 = new Array("Protozoa", "Amoeba (Sarcodina)", "Dientameoba fragilis (may be a flagellate)", "", "Global", "5-12 ยต", "Definitive host → free-living stage → host", "Trophs in stool", "Mouth", "Large intestine", "Diarrhea, abdominal discomfort (yet often asymptomatic)", "Trophs in stool", "Iodoquinol or Paromomycin & tetracycline", "Large intestine", "", "Mistake for Entamoeba histolytica; also often seen with pinworms", "Trophozoite (→no cyst)", "");

var choice2 = new Array("Protozoa", "Amoeba (Sarcodina)", "Acanthamoemba spp Naegleria fowleri", "Granulomatous Amebic Encephalitis (often post-mortem", "Global", "", "Definitive host → free-living stage → host", "Stagnant water; ponds or lakes", "Nose", "Brain, eye & \"other\" (man accidental host)", "No symptoms to symptoms of organic brain syndrome; meningoencephalitis", "", "Amphotericin B (highly toxic)", "Spp. from soil----Naelgeria from water", "Soil?", "", "Free-living ameoba", "");

var myVal = this.rawValue;
myVal = xfa.event.newText;
//if(myVal == "Dientameoba fragilis")
if(this.rawValue == 1)
{
Comparison1.TaxonomyA.rawValue = choice1[0];
Comparison1.TaxonomyB.rawValue = choice1[1];
Comparison1.Organism.rawValue = choice1[2];
Comparison1.CommonName.rawValue = choice1[3];
Comparison1.WorldLocations.rawValue = choice1[4];
Comparison1.Size.rawValue = choice1[5];
Comparison1.LifeCycle.rawValue = choice1[6];
Comparison1.InfectiveForm.rawValue = choice1[7];
Comparison1.Portal.rawValue = choice1[8];
Comparison1.Site.rawValue = choice1[9];
Comparison1.MostCommon.rawValue = choice1[10];
Comparison1.LabDiagnosis.rawValue = choice1[11];
Comparison1.TherapeuticAgents.rawValue = choice1[12];
Comparison1.AsexualLocation.rawValue = choice1[13];
Comparison1.SexualLocation.rawValue = choice1[14];
Comparison1.RemarksCautions.rawValue = choice1[15];
Comparison1.Notes.rawValue = choice1[16];
Comparison1.InternalLinks.rawValue = choice1[17];
}

//if(myVal == "Acanthameomba spp Naegleria fowleri")
if(this.rawValue == 2)
{
Comparison1.TaxonomyA.rawValue = choice2[0];
Comparison1.TaxonomyB.rawValue = choice2[1];
Comparison1.Organism.rawValue = choice2[2];
Comparison1.CommonName.rawValue = choice2[3];
Comparison1.WorldLocations.rawValue = choice2[4];
Comparison1.Size.rawValue = choice2[5];
Comparison1.LifeCycle.rawValue = choice2[6];
Comparison1.InfectiveForm.rawValue = choice2[7];
Comparison1.Portal.rawValue = choice2[8];
Comparison1.Site.rawValue = choice2[9];
Comparison1.MostCommon.rawValue = choice2[10];
Comparison1.LabDiagnosis.rawValue = choice2[11];
Comparison1.TherapeuticAgents.rawValue = choice2[12];
Comparison1.AsexualLocation.rawValue = choice2[13];
Comparison1.SexualLocation.rawValue = choice2[14];
Comparison1.RemarksCautions.rawValue = choice2[15];
Comparison1.Notes.rawValue = choice2[16];
Comparison1.InternalLinks.rawValue = choice2[17];
}

StevenD

My Product Information:
LiveCycle Designer, Windows
StevenD
Registered: Oct 6 2006
Posts: 368
After slaving over this problem the last two days I finally discover quite by accident that I need to put "boundItem" in the line of code that gets the value of the dropdown like this.

var myVal = boundItem(xfa.event.newText);

StevenD

StevenD
Registered: Oct 6 2006
Posts: 368
Okay so that works.

var myVal = boundItem(xfa.event.newText);

gets the export value of the item chosen from the dropdown field. So if I choose item one the export value (in this case) is 1. Now I just need to combine the value with "choice" and "[0]" to make up "choice1[0]" for example and have it not be a string.

StevenD