Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

Drop downs

Avatar

Former Community Member
without making drop downs global (because I have an add button to re-create the subform for an invoice) how can I make the value of one drop down effect the other?
19 Replies

Avatar

Former Community Member
Well, I think you're asking how to make it so that choosing a choose in one drop down sets that choice in another drop down. You can do this with a script on the change event of the first drop down, here's the basic script, you'd need to change the path to the second drop down to be specific to your form:



DropDown2.rawValue = xfa.event.newText;



Chris

Adobe Enteprise Developer Support

Avatar

Former Community Member
Chris:



How does this work?

I have multiple choices in the first drop down and multiple choices in the second drop down. I dont understand how to make it so that if the first raw value = 1, then the second raw value is = 1. I was going to do this by making them global, but then once the subform is repeated it connects those fields as well.



I guess what I am saying is that i dont understand: DropDown2.rawValue = xfa.event.newText; how do I path this for each choice?

ie: if press room is selected the price drop down defaults to 350.00...would this be easier by just using a text field and calculate methods?

Avatar

Former Community Member
Ok, let me ask you this. In your form have you specified specified values for items that are different from their text (ie: in the binding tab for the drop down field in Designer). That would make the scripting easier to describe, but is not necessary to get things to work. Let me know and I'll try to explain better.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Yes each item in the first drop down (rooms) is linked to the same raw value as the second drop down (price).



So sorry to be such a pain, as you can tell I have no scripting experience, I am learning as I go

Avatar

Former Community Member
No problem at all. So if that's the case then your script on the change event of the first drop down list should be:



DropDown2.rawValue = xfa.event.newText;



Changing DropDown2 to the name of your second drop down list is all you need to do if the first and second drop down's are both under the same parent in the form hierarchy. If they aren't, then you need to use a full path to the 2nd drop down list starting from the top level form node. If you're not sure what to use as the path to the 2nd drop down list, you can put the following script on the initialize event, temporarily, of the 2nd drop down. It will show a messageBox telling you the SOM expression of the field. You should be able to just copy and paste that.



xfa.host.messageBox(this.somExpression);



P.S. All the descript I've described is JavaScript not FormCalc.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
this doesnt work in java script, in formcalc its copying over the description but it is not producing the dollar amount in the second drop down, do you have an e-mail that I can send this to? apparently I have no idea what I am doing.

Avatar

Former Community Member
My bad, that didn't work at all. I've attached a small sample, you can see the script used on the calculate event of drop down 2.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
ok last question, how can I get the value to multiply and return the dollar value times a given number, rather than the raw value?

Avatar

Former Community Member
Also, how do I limit selections in drop downs to specific items, for instance one dropdown is meal type (breakfast, lunch etc) the second needs to limit the drop down to the items with the same raw value. all breakfast items have a raw value of 1, because breakfast in the first dropdown has a raw value of 1 etc...



sounds easy but I cant get it to work



Thanks again, you've been a life saver

Avatar

Former Community Member
> ok last question, how can I get the value to multiply and return the > dollar value times a given number, rather than the raw value?



I'm confused. You're using a drop down list, so you have a finite selection of dollar values from which to choose. Whatever dollar amount you want to be chosen, you should set the rawValue of that drop down to be the rawValue that corresponds to the item that displays the dollar value you want.



> all breakfast items have a raw value of 1, because breakfast in the

> first dropdown has a raw value of 1 etc...



All item in a drop down should have a unique rawValue. It's basically an index that identitifies a specific item in the drop, so it doens't make sense to have multiple items with the same rawValue as you would never know which is which.



> Also, how do I limit selections in drop downs to specific items, for > instance one dropdown is meal type (breakfast, lunch etc) the second > needs to limit the drop down to the items



For this you'll need to dynamically populate the 2nd drop down via script based on the selection in the first drop down. I've attached a simple example, you can see the script on the exit event of the 1st drop down.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Ok so using your example I tried this script:



if (this.rawValue == 0) { //Continental Breakfast

DropDownList2.clearItems();

DropDownList2.addItem("The Time Out", "0");

DropDownList2.addItem("In The Zone", "1");

DropDownList2.addItem("The Major League", "2");

DropDownList2.addItem("The All-American", "3");

} else { //Hot Breakfast

DropDownList2.clearItems();

DropDownList2.addItem("MVP", "0");

DropDownList2.addItem("Wasatch Mountain Quiche", "1");

DropDownList2.addItem("The Gold Medal", "2");

DropDownList2.addItem("The All-Star", "3");

DropDownList2.addItem("The Hall of Famer", "4");

} else { //Morning Breaks and Snacks

DropDownList2.clearItems();

DropDownList2.addItem("Sunrise Break", "0");

DropDownList2.addItem("Uintah Mountain Break", "1");

DropDownList2.addItem("The Great Salt and Sweet Lake Break", "2");

} else { //Luncheons

DropDownList2.clearItems();

DropDownList2.addItem("Box Lunches", "0");

DropDownList2.addItem("Lite Lunch", "1");

DropDownList2.addItem("Pre-Plated Lunch", "2");

DropDownList2.addItem("Deli Torpedo Sandwich", "3");

DropDownList2.addItem("Deli Platter Buffet", "4");

DropDownList2.addItem("It's a Wrap", "5");

DropDownList2.addItem("Wasatch Executive Lunch", "6");

} else { //Late Afternoon Snacks

DropDownList2.clearItems();

DropDownList2.addItem("Deluxe Mixed Nuts", "0");

DropDownList2.addItem("Prestzel Twists", "1");

DropDownList2.addItem("Popcorn Bowl-Large", "2");

DropDownList2.addItem("Tortilla Chips with Guacamole & Salsa", "3");

DropDownList2.addItem("Plain Potato Chips with Onion Dip", "4");

} else { //Hot Lunch Sandwich Specials

DropDownList2.clearItems();

DropDownList2.addItem("Western BBQ Sandwiches", "0");

DropDownList2.addItem("Philidelphia Via Paris", "1");

} else { //International Hot Lunches

DropDownList2.clearItems();

DropDownList2.addItem("A Little Bit of Italy", "0");

DropDownList2.addItem("South of the Border", "1");

DropDownList2.addItem("Asian Station", "2");

} else { //Hot Lunches

DropDownList2.clearItems();

DropDownList2.addItem("Sliced Citrus Ham", "0");

DropDownList2.addItem("Traditional Chicken Parmesan", "1");

DropDownList2.addItem("Old-Fashioned Pot Roast", "2");

DropDownList2.addItem("Grilled Chicken Breast", "3");

DropDownList2.addItem("Prosciutto Wrapped Chicken", "4");

DropDownList2.addItem("Baked Orange Roughy", "5");

DropDownList2.addItem("Baked Hailbut with Lemon Dill Sauce", "6");

DropDownList2.addItem("Shrimp Scampi", "7");

}

And its not working... I retitled my second dropdown (for simplification DropDownList2...

Avatar

Former Community Member
Your syntax is a little off, it should be:



if (this.rawValue == "0") {



} else if (this.rawValue == "1") {



} else if (this.rawValue == "2") {



} else if (this.rawValue == "3") {



} else if (this.rawValue == "4") {



} else if (this.rawValue == "5") {



} else if (this.rawValue == "6") {



} else {



}



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Thank you thank you thank you!



I am still trying to come up with a solution for the mutiplication issue. I need to calculate an hourly rate.



I was going to use the hourly rate as a raw value, but they duplicate so I cant do that. but I cant use 1-11 or it multiplies by that number



Any suggestions?

Avatar

Former Community Member
I'd suggest not using a drop down and instead using a text or numeric field to display the hourly rate.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Well chris after all this work, adobe did it to me again, it gave me an error and cleared out my file, 3 days of work down the drain. 0KB file now. Any idea why it does this, it has happened to me severl times

Avatar

Former Community Member
Jaime_Elmen@adobeforums.com wrote:<br />> Well chris after all this work, adobe did it to me again, it gave me an error and cleared out my file, 3 days of work down the drain. 0KB file now. Any idea why it does this, it has happened to me severl times<br /><br />This has happened to me as well. I'm not sure why it occurs. However, <br />if you have been using the PDF Preview tab to preview the form, then you <br />can recover some if not all of your work. If you are using Windows XP, <br />then open up an Explorer window and navigate to C:\Documents and <br />Settings\<your_profile_name>\Local Settings\Temp. In there you will see <br />a bunch of PDF files. These are PDFs that are generated each time you <br />click on the PDF Preview tab in Designer. Sort by date and find the <br />most recent one. You can then open that PDF in Designer and hopefully <br />recover most if not all of the work you did.<br /><br /> Justin Klei<br /> Cardinal Solutions Group<br /> www.cardinalsolutions.com

Avatar

Former Community Member
No, i'm not sure why it does that as I've never had that happen to me. I'm sorry you lost your work, and hopefully you can recover it using Justin's suggestion.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Regarding the 0K file, I've found that if I have more than one form field, subfield, etc. bound to the same node I often get the "0K" error. I think this happens to me when I do some copy/pasting and just forget to change the bindings. I've now gotten into the habit of checking the file properties in Win Explorer to ensure it's > 0k before I close the file down. I do feel ya, I've lost hours of work myself with the same issue.



Since this thread is a couple months old, I hope you're doing better on your project than mine :D.



Hope that also helps adobe possibly recreate the issue and maybe include some alert upon saving the file to prevent this. For what it's worth, I saw this when binding to XML. I haven't seen it with binding to a schema, but the forms are also more stabalized and don't change nearly as much.



take care,

l

Avatar

Former Community Member
Hi,



I have looked at the sample PDF file and I cannot seem to find where you put the script into the form. The dropdown menus dont seem to be referencing any javascript.



I using Acrobat Pro 8 now and I was surprised that given the amount of queries on Dynamic dropdown menus, that Livecycle 8 has not addressed this problem by having Dynamic dropdown menu options.



Cheers