Expand my Community achievements bar.

Linking Drop Downs to Pricing

Avatar

Level 2
Hi, I need two drop downs, one for Quantity and one for Item Number. For example, if I choose 250 for quantity and item number 12345 I want to autopopulate the pricing category with the correct pricing for this combination. Does anyone know what javascript I use to do this? THIS IS URGENT, NEED ANSWER TODAY, APRIL 24TH.



Thanks.
3 Replies

Avatar

Former Community Member
There is a sample that shows this look at your install directory and navigate to EN\Samples\Forms\Purchase Order\Dynamic Interactive\Forms and look at the purchaseOrder sample. The table that is in there does exactly what you want.

Avatar

Level 2
No it doesn't. I want to use combination of each item in each drop down field, it only allows one format and that's it. does anyone know how to do this?

Avatar

Former Community Member
Kim,

I assume you have your binding set up for both drop down fields (ddQuantity and ddItemNumber). I would solve this with the following. First set up three hidden text fields (HiddenQuantity, HiddenItemNumber, and HiddenItemPrice). On the change event for the ddQuantity drop down field put the following javascript code:



HiddenQuantity.rawValue = xfa.event.newText;



For the Item price it is a little trickier because you need to have your javascript set up to associate an item number with a price. You will need to set up the calculate event for the HiddenItemPrice field to get you the item price when given an Item Number (you'll end up using the value you store in the HiddenItemNumber field to make this association). Once that is set up the change event on the ddItemNumber drop down field should have the following code:



HiddenItemNumber.rawValue = xfa.event.newText;

HiddenItemPrice.execEvent("calculate");



This will first set the value of the HiddenItemPrice field to the selected value from the Item Number dropdown, and then calculate the Item Price based on that value. Lastly the pricing field should have the following javascript in the calculate event:



this.rawValue = HiddenQuantity.rawValue * HiddenItemPrice.rawValue;



This will give you the total pricing for the entire selected quantity. If you have multiple rows of dropdowns (quantity and item number) then each row would need it's own set of hidden fields. Hope this helps.