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

Select a dropdown entry based on checkbox

kellston
Registered: Jul 5 2010
Posts: 30

I am very new to this. My first post.
I am creating a form where I have a drop downlist and I want one of the dropdown selections picked automaticlly if a checkbox is checked.
I just cant get it to heppen.
Any ideas?

My Product Information:
LiveCycle Designer, Windows
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can do this with the setItemState property.
A small JavaScript in the change:event of the checkbox can control the preselection of an item of the drop down box.

if(this.value.integer.value == 1){//Select first entry of the drop down box entries (0 = first entry , 1 = second entry etc.).  DropdownList1.setItemState(0, true);}else{DropdownList1.rawValue = null;}

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

kellston
Registered: Jul 5 2010
Posts: 30
Thank you for your reply but it is not working for me.
I have put this code in the calculation filed for the checkbox:

if(this.value.integer.value == 1)
{
//Select first entry of the drop down box entries (0 = first entry , 1 = second entry etc.).
Dropdown1.setItemState(12, true);
}
[else
{
Dropdown1.rawValue = null;


The name of the checkbox is CheckBox1 and the drop down is Dropdown1.
I want the drop down to select the 12th entry if the checkbox is selected.
I am not sure what I am missing.
I tried it as a dynamic pdf as well.
Thanks for your help
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Don't use the calculate:event, use the change:event as suggested before.

to get the 12th entry the code is:
Dropdown1.setItemState(11, true);

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

kellston
Registered: Jul 5 2010
Posts: 30
Still not working.
Are there some other settings I am missing?
Thanks for your help
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Language is JavaScript, ensure it is selected in the script editor.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

kellston
Registered: Jul 5 2010
Posts: 30
I have entered the code with the change function.
I am using javascript.
When I select the check box nothing changes.
Are there any specific values I need in the drop down?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Check the JavaScript console (ctrl + j) in Acrobat for any errors.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

kellston
Registered: Jul 5 2010
Posts: 30
I removed the brackets and it is working thank you very much!!

If I want it to check a second field as well to make sure there is a number in it and the checkbox is checked can I do that?
I tried this below but with no luck

if((this.value.integer.value = 1)&(box2.value >0)) ddd1.setItemState(1, true);else ddd1.rawValue = null;Thanks alot!
LeeRain
Registered: Jul 7 2010
Posts: 3
Still not working.
Are there some other settings I am missing?
Thanks for your help
__________________
[url=http://www.onlinedatingportfolio.com/]Online Dating Reviews[/url]
[url=http://www.myhealthysexlife.com/category/health-articles/]Healthy sex[/url]

Lee Rain

kellston
Registered: Jul 5 2010
Posts: 30
Hello radzmar,
Thanks for your help.
Is there a way to add one more condition to this formula?
if((this.value.integer.value = 1)&(box2.value >0)) ddd1.setItemState(1, true);else ddd1.rawValue = null;
then I want it to check that Box1 has a value in it any number other than zero before it populates the dropdown

Thank for your help.
Sorry Germany did not win the World Cup!
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

if you want to check two different source for a specific value to populate the dropdown list, its better to put the script into the layout:ready event of the dropdown list.

// Check if Box1 is 1 and Box 2 is not 0if(Box1.value.integer.value == 1 && Box2.value.integer.value != 0){this.setItemState(1, true);}else{this.rawValue = null;}

Well, we didn't win the World Cup, but we've played the better final (match for the 3rd place) ;-)

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs