Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Drop down list issue

Avatar

Former Community Member
Hi I am working on form which has a drop down box with 3 different values.

Different textfield Item have to appear on the page according to the value selected in dropdown list.

Problem is that I have to select each value from the dropdown list TWICE to make the corresponding textfield Item appear on the page.

Can you please help me with this?



I ran a javascript on "change" event and use Adobe Livecycle designer 8.

I can post javascript I use, if you want.
16 Replies

Avatar

Level 6
In your change event script, reference the drop-down's new value as xfa.event.newText, not as this.rawValue.

Avatar

Former Community Member
It works! Thanks Jared.



I have another issue.In the 7 page form I am creating, each page has to have 7 tickboxes. When each page is filled by user, the corresponding tickbox is marked.



Eg after filling first 2 pages of form, when I browse to 3rd page then the first two tickbox should be marked. And so on...



Any ideas on how to do it?

Avatar

Level 6
How do you define a page as having been filled? Do all mandatory fields on the page need to have valid values? Assuming that's the case, you could put a calculation script on the checkbox like this:



if (xfa.form.form1.Page1.execValidate())

this.rawValue = 1;

else

this.rawValue = 0;



This code won't execute on its own, you need to force it with

CheckBox1.execCalculate();



You put that code (execCalculate) on other events that you expect to happen fairly frequently. For example, on enter and on exit of some subforms. Definitely on prePrint and preSave.



Maybe someone else has another idea.

Avatar

Former Community Member
Hi Jared,



Many thanks for the answer.Sry, I got busy in some work.



Each page has some textfield, dropdown list and radio buttons, which are to be filled mandatorily.



I am not very sure how to apply what you told. Can you please tell me in step by step manner.

Avatar

Level 6
Here's something you can do to better understand what's going on.



To make a field mandatory, select the field and set the Type to "User Entered - Required". The Type is in the Value tab of the Object palette. Let's say your object is on the first page of your form, which you've named "Page1". Let's also say that you haven't renamed the root node of your form from the default, "form1".



Now add a button to your form with this Javascript in the click event:



if (xfa.form.form1.Page1.execValidate())

xfa.host.messageBox("all the fields on page 1 are valid");

else

xfa.host.messageBox("there are invalid fields on page 1");

Avatar

Former Community Member
Hi Jared,



This seems to work. But can it be done without pressing any button?



Also there some hidden fields on the page, which show up as per the selections made in top section of the page. These hidden fields are mandatory as well. This is creating a problem here



Can you please tell me the javascript code for making Type to "User entered - Optional"



Or is there any other way to do it?

Avatar

Level 6
You can run a validation on any script, not just a button click. To set a field to mandatory in script:



myField.validate.nullTest = "error";



To set it to not mandatory:



myField.validate.nullTest = "disabled";

Avatar

Former Community Member
Thanks Jared...I will keep you posted on the Validation script thing.



i tried this



"user entered - required"

this.mandatory = "error";



To make it "user entered - optional" again,

this.mandatory = "disabled";



its working fine too.



But doubts seem never ending, the form I am working on is turning out to be complex than what it was perceived initally.



Please tell me the Javascript code for making default Binding Normal or Global...I am unable to find it anywhere.

Avatar

Former Community Member
Going back to the original post on this subject - can someone explain how I can auto-fill specific text fields/boxes based on what the users selects in a dropdown list?

Example:

Dropdown list has 3 items: Apple, Orange, Peach.

When a user selects "Peach", it needs to auto-populate in particular spots within the form.



I'm unable to correlate the blank fields with my dropdown list. What are the steps/scripts/fields needed to make this work?

Avatar

Former Community Member
In the above example, do you want to autofill with what has been selected?



Supposing, if thats the case, run the following script in the calculate event of the "textfield"



dropdownfield.rawValue



here "dropdownfield" is the name of the dropdown list with apple, peach, orange.

Now in the intialize event of the "dropdownfield" paste this:



if (this.rawValue == null)

{ this.rawValue = " ";

}



For alternative solution, read this thread.



Regards

GS

Avatar

Former Community Member
This topic seems to be the closest to what I am trying to accomplish.



I am a complete amateur in regards to adobe 8 Live Cycle.



My goal is to create a drop down list and (based upon the selection) certain information will appear on the second page that has been pre-programmed.



Any help would be greatly appreciated.

Avatar

Former Community Member
Hi Codynoren,



You can make the information on Page2 appear "visible" depending on the selection made in the dropdown list



Run this type of script in "Change" event of the dropdownlist



switch (xfa.event.newText) {

case "Option1":

page2.field1.presence = "visible";

page2.field2.presence = "visible"; break;

case "option2":

page2.field1.presence = "hidden";

page2.field1.presence = "hidden";

break;

}

here page2.field1 etc are valid XFA address of the fields on page 2.



Rgds



GS

Avatar

Former Community Member
OK, I'm trying to make the above code work, but it's not. I have adapted it as posted below. By default I have my text field set to "invisible." My drop-down list and my text field are in the same subform as I want them to be side-by-side. Could this be my issue or am I just missing something really basic?



switch (xfa.event.newText)

{

case "New position":

form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "visible";

break;

case "Establish a generic position":

form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "invisible";

break;

case "Delete a position":

form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "invisible";

break;

case "Review and update a position":

form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "visible";

break;

case "Reclassify a position":

form1.ClassificationSection.ClassificationRequest.SubmitJobDescription_Note.presence = "visible";

break;

}

Avatar

Former Community Member
Hi all,



Please disregard my previous post. The code works perfectly, the problem was that my form was saved as a static pdf and not dynamic.

Avatar

Level 2
OK, I have entered the script in my document



if (this.rawValue == null)

{ this.rawValue = " ";

}



and I have also enter the calculation script as well



dropdownfield.rawvalue



Now, how do I make sure that when I select, for example "250" from the dropdown list, I get $415.00 in the corresponding field.



URGENT HELP IS NEEDED! Form is due out today.

Avatar

Former Community Member
Kim, I am not sure if this is what you want. Using JS and on the Exit Event try this code. Your DD list has three items, Specify Item Values under binding. If the Value is 1 (Apples) it populates 2 fields on 2nd page - type and color, or if Value is 2 (Oranges), populates the type and color, or Value of 3 (Bananas), populates its type and color. This was built for Designer 7.1.2 with Reader 7.0.9 / 8.1.2 in mind.



if (this.rawValue == 1){

P2.TextField1.rawValue = "MacIntosh";

P2.TextField2.rawValue = "Red";

}

else if (this.rawValue == 2){

P2.TextField1.rawValue = "Navel";

P2.TextField2.rawValue = "Orange";

}



else if (this.rawValue == 3){

P2.TextField1.rawValue = "Dole";

P2.TextField2.rawValue = "Yellow";

}