I hope I can explain this properly...
Lets say I have a drop down list in box "A"...I want a drop down list in box "B" to display options dependent on what is selected from Box "A".
e.g.
If box "A" is selected as "month"...I want box "B" to have pulldown options of "JAN, FEB, MAR" etc
if box "A" is selected as "year"...I want box "B" to give options as "2012, 2011, 2010" etc
I am using Livecycle Designer 8.0 if that matters...
Can someone provide guidance?
thanks so much in advance!
John
Views
Replies
Total Likes
Hello,
You can write the script in the PreOpen event of the drop down list boxB as follows:
if(boxA.rawValue == "month")
{
boxB.clearItems();
boxB.addItem("JAN");
boxB.addItem("FEB");
boxB.addItem("MAR");
}
if(boxA.rawValue == "year")
{
boxB.clearItems();
boxB.addItem("2012");
boxB.addItem("2011");
boxB.addItem("2010");
}
Thanks,
Debadas.
Views
Replies
Total Likes
Hi John,
Just noticed Debadas posted a solution while a was checking mine works. Mine is basically the same (in the same event) but just wanted to point out that if you are targeting Reader 9 or later then you can use the setItems method which makes things a little easier, as you can load all the items in one hit (though maybe with an older version of Designer that wont work, but thought I might as well add my bit).
switch (DropDownA.rawValue)
{
case "Month":
// this.setItems("January,February,March,April,May,June,July,August,September,October,November,December");
this.clearItems();
for (var i = 0, currentDate = new Date(2012,0,1); i < 12; i++, currentDate.setMonth(currentDate.getMonth() + 1))
{
this.addItem(util.printd("MMMM", currentDate, true))
}
break;
case "Year":
this.setItems("2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001");
break;
}
Bruce
Views
Replies
Total Likes
I tried this code in LifeCycle. I entered it in the script editor of boxb with the settings: PreOpen, JavaScript, Server. I receive the following error message.
__________________________________________________________________
Script failed (language is formcalc; context is xfa[0].form1[0].#subform[0].boxa[0])
script=if (this.rawValue == GSS)
{
this.parent.OrganizationNumber.selectedIndex = a
}
Error: syntax error near token "{" on line 2, column 1.
___________________________________________________________________
Below is the script I entered.
form1.#subform[0].boxa::preOpen - (FormCalc, server)
if(boxa.rawValue == "GSS")
{
boxb.clearItems();
boxb.addItem("JAN");
boxb.addItem("FEB");
boxb.addItem("MAR");
}
if(boxa.rawValue == "Healthcare")
{
boxb.clearItems();
boxb.addItem("2012");
boxb.addItem("2011");
boxb.addItem("2010");
}
----------------------------------------------------------------
Either there is an error in my script, or I am not setting the drop-down boxes up properly prior to writing the script. Prior to the script do I need to enter any list items in the right-hand side box for either boxa or boxb? I entered "GSS" and "Healthcare" in boxa and "JAN", "FEB", "MAR", "2012", "2011", "2010". Where does the script pull from when identifying the two different boxes' names? The object->field->caption box or object->binding->name box?
*Step-by-step instructions would be extremely helpful, starting from scratch. ie. "place two blank drop-down menus on the worksheet." and so on.
Thank you in advance!
Views
Replies
Total Likes
Hi,
A couple of things:
There is an example here: http://assure.ly/jcTahK.
Hope that helps,
Niall
Views
Replies
Total Likes
Views
Likes
Replies