Expand my Community achievements bar.

SOLVED

Help to associate drop down menu choices with prices in another field

Avatar

Level 1

Hello.  : (

I am not really a programmer.. but I have written code before.

(Certainly never written in JavaScript..)

I am working for some non-profit and they asked me to fix their PDF to associate prices with items..

I thought that this would be relatively simple in LiveCycle.. but not for me, anyway..

I have some fields called Description0, Description1, etc.. that are a DROP DOWN menu that lets you select some option.

I want the option to associate with a price field and update depending on the item selected in the drop down menu.

I am totally failing though, it would seem..

Any tips would be appreciated. : )

I wrote something like this:

function descriptionChange(newDescription){

switch(newDescription){

          case "Lifepak CR Plus Charge Pak (one set of electrodes and one battery)":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "80";

                              break;

          case "Lifepak CR Plus Charge Pak (two sets of electrodes and one battery)":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "107";

                              break;

          case "Lifepak CR Plus Pedi Pad Starter Kit":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "139";

                              break;

          case "Lifepak CR Plus replacement pedi pads":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "99";

                              break;

          case "Philips HeartStart FRx Battery":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "153";

                              break;

          case "Philips HeartStart FRx Adult Pads (1 Set)":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "50";

                              break;

          case "Philips HeartStart FRx Infant/Child Key":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "98";

                              break;

          case "Zoll Type 123 Lithium Batteries, (10) lasts 5 years":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "75";

                              break;

          case "Zoll CPR-D Padz, five year year shelf-life":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "169";

                              break;

          case "Zoll Stat Pads II, Two (2) piece pads, 2 year shelf-life":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "59";

                              break;

          case "Cardiac Science G3 Plus Battery":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "395";

                              break;

          case "Cardiac Science G# plus Pads (1 set)":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "49.95";

                              break;

          case "Wall Cabinet":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "200";

                              break;

          case "AED Wall Sign-3D":

                    this.resolveNode("UnitPrice.UnitPrice").rawValue = "15";

                              break;

}//end switch

}//end function

and then for each Description0,1... I put in like this:

var newDescription = this.boundItem(xfa.event.newText);

DescriptionChange.descriptionChange(newDescription);

Help please? : )

Sorry if my question is too simple.. or I am just too much of a failure..

1 Accepted Solution

Avatar

Correct answer by
Level 8

When you create your drop down, after you put in your list of items, select the Binding tab in your Object palette. Check "Specify Item Values". For each item edit its numerical value (ex. Text:"Lifepak CR Plus Charge Pak (one set of electrodes and one battery)" value would be 80).

In the calculate event of your UnitPrice field select the language FormCalc and insert the script:

sum(Discription0,Description1)

Adding whatever drop downs you need to be included in the total.

Hint: Name all your dropdowns the same thing and all you have to put for script is: sum(Description[*])

Kyle

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

When you create your drop down, after you put in your list of items, select the Binding tab in your Object palette. Check "Specify Item Values". For each item edit its numerical value (ex. Text:"Lifepak CR Plus Charge Pak (one set of electrodes and one battery)" value would be 80).

In the calculate event of your UnitPrice field select the language FormCalc and insert the script:

sum(Discription0,Description1)

Adding whatever drop downs you need to be included in the total.

Hint: Name all your dropdowns the same thing and all you have to put for script is: sum(Description[*])

Kyle

Avatar

Level 1

Thank you!!!

That is a really nice trick. : )

I ended up referencing the values with JavaScript actually..

but I imagine it is effectively the same.

They are referenced like this if anyone is curious in the future...

UnitPrice.rawValue =  Description.rawValue;

I also thought I might have a problem in the future if each price associated was not unique -- but that also doesn't matter... super great. : )

Thank you very much.