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

Make text field visible when user selects option from drop down

samrao
Registered: Jan 4 2010
Posts: 5

Hi, I am not sure if this has already been covered in a different thread but I am new to livecycle and have desiged my first form that will be used in my IT company I work for. The form will be used for daily tasks that a user fills in.

What I am trying to figure out is how to make a field visible only when the user selects a certain option for example in my case:

The dropdown has 2 options, Yes and No. If the user selects Yes then 1 or 2 text boxes will appear where the user can fill in information. I want it so the text box is invisible unless the user selects Yes. How do I do this?

thanks
Sam

My Product Information:
LiveCycle Designer, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi samrao,

I believe there are some example files showing this feature in the Gallery section of this site. Those files are not secured so the code used can be examined. There are also tutorials in the Learning Center as well as some on demand e-seminars on LiveCycle Designer Forms that cover showing and hiding fields. So, yes this can be done- just a matter of spending some time reading, trying and testing it out.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
samrao
Registered: Jan 4 2010
Posts: 5
Hi, thanks for the reply but I am still having trouble finding the correct information. I searched on the tutorials but can't find anything and don't see anything relating to what I am looking for. I will check out the seminars but if you are able to point me in the right direction to the exact example form or tutorial where I will find the answer?

Thanks
kez82
Registered: Jan 7 2010
Posts: 7
Hi samrao,

I think this is exactly what I am trying to do. Did you manage to find out what the acction is called or if you know of any useful tutorials??

Cheers, Kez82
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi samrao,

Check out the "Computer Setup Checklist" in the Forms Gallery. It shows how to show/hide fields based on a check box selection- this can be adapted to work with a dropdown.

In the e-seminar area of the Learning Center- watch the one titled "Extending LiveCycle Forms with JavaScript and FormCalc "

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
kez82
Registered: Jan 7 2010
Posts: 7
Hi Dimitri,

Thanks so much. I have found the e-seminar and the questions and answers wtihin it very useful.

Another thing I am trying to do is create a document in Livecycle whereby depending on what checkbox you tick, it imports a pdf document directly into the document. Similar to like a hyperlink or when you are in MS Word and you import a file. Is this possible??

Cheers,
Kez82
samrao
Registered: Jan 4 2010
Posts: 5
Thanks for the help, I managed to find the solution and it works great but now I am having trouble trying to get checkbox fields to grey out and disable or get them to hide using the same statement.

If I try the script below on a checkbox it does not work hiding other checkboxes:

if (checkbox1 == "1") then
checkbox2.presence = "visible"
else
checkbox2.presence = "hidden"
endif

looked at turorials but not been able to figure it out yet, disabling the other checkboxes would be better. What I want to do is have it so if the user selects 'None' then it will disable all other boxes, this is to stop them from accidently selecting None and other options.
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi samrao,

You could create radio checkboxes so that only one choice is allowed- i.e., if they choose None then no other checkbox in the group could be checked. See this article on creating radio checkboxes-
http://www.acrobatusers.com/tutorials/creating-radio-checkboxes

You can also gray our fields based on the selection. See this article on disabling/graying-out fields-
http://www.acrobatusers.com/tutorials/2007/09/js_disabling_fields

Hope this helps,

Dimitri
www.pdfscripting.com
www.windjack.com
adobetech55
Registered: Apr 18 2008
Posts: 9
The form Computer Set-Up Checklist is really close to what I need. How do I view the script on this form?
Thanks for the help.
SLDC
Registered: Oct 25 2010
Posts: 70
Select a form element, and make sure the Script Editor (Windows menu) is set to show "Events with Scripts".
Devil4CE
Registered: Nov 21 2011
Posts: 6
Hi people,

I'm desperate and need really help!

I have a drop-down box (which name is "enfants" kids in english) on my form which has only 5 options from "0" to "4".
This should give the user the possibility to chose between 1 to 4 childes.

I want that the text boxes where the user has to put information of the child like "name", "first name" and so on to show when they select from the drop-down box...

I wrote this script but it doesn't work, and I don't have a clue why... so if someone can help me, I will be very grateful!!!

my script:

var enfants
{
if (enfants.value=="0")
this.getField(["Text1","Text2","Text3","Text4","T1","T2","T3","T4","Tex1","Tex2","Tex3","Tex4","Te1","Te2","Te3","Te4"]).display.hidden;

else if (enfants.value=="1")
this.getField(["Text1","Text2","Text3","Text4"]).display.visible;

else if (enfants.value == "2")
this.getField (["Text1","Text2","Text3","Text4","T1","T2","T3","T4"]).display.visible;

else if (enfants.value == "3")
this.getField(["Text1","Text2","Text3","Text4","T1","T2","T3","T4","Tex1","Tex2","Tex3","Tex4"]).display.visible;

if (enfants.value == "4")
this.getField(["Text1","Text2","Text3","Text4","T1","T2","T3","T4","Tex1","Tex2","Tex3","Tex4","Te1","Te2","Te3","Te4"]).display.visible;

endif;
}

Please Help me
Thank you all