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

Combo box population problem

tehashi
Registered: Jun 30 2009
Posts: 20
Answered

I used the tutorial [url=http://www.acrobatusers.com/tutorials/2006/change_another_field]'Changing Another Field with Combo Box (Drop Down) Selection'[/url] to set up a 2 option combo box to allow users to select either 'Standard Price' or New York Price' pricing structures. The combo box is set to when a choice is made it changes the values of several invisible text fields to the required prices that are used in calculating total pricing for whatever number of units.

My problem arises from the fact that the combo box will change the text field values to the New York pricing with no problems, but will not change them back to normal pricing when Standard is then selected from the combo box. The default value of the text fields is the Standard price, so the current setup can change from Standard to New York, but not back to standard.

Here is the document script i used, modified directly from the above tutorial;

var PricingData = { "New York Price":{ "Screens": "105",
"ScreensCMOnly": "75",
"ScreensII": "115",
"CSafe": "20.30",
"NonCsafe": "23.10",
"MCT": "98",
"MCTCards": "17.20",
"1CT": "51.10",
"IR": "18",
"IIController": "28",
"CCReceiver": "14",
"CCServer": "171.50",
"1stHour": "120",
"AddlHour": "80",
"Mileage": "0.95",                               
                 "Standard Price":{ "Screens": "87.50",
"ScreensCMOnly": "50",
"ScreensII": "97.50",
"CSafe": "8.75",
"NonCsafe": "10.50",
"MCT": "60",
"MCTCards": "15",
"1CT": "21",
"IR": "16",
"IIController": "26",
"CCReceiver": "12",
"CCServer": "150",
"1stHour": "65",
"AddlHour": "65",
"Mileage": "0.95" }}};
 
function SetFieldValues(cPricingType)
{
   this.getField("DefaultScreenTechVal").value = PricingData[cPricingType]["Screens"];
   this.getField("12CMOnlyTechVal").value = PricingData[cPricingType]["ScreensCMOnly"];
   this.getField("12wPTechVal").value = PricingData[cPricingType]["ScreensII"];
   this.getField("CsafeTechVal").value = PricingData[cPricingType]["CSafe"];
   this.getField("NonCsafeTechVal").value = PricingData[cPricingType]["NonCsafe"];
   this.getField("MCTTechVal").value = PricingData[cPricingType]["MCT"];
   this.getField("MCTCardsTechVal").value = PricingData[cPricingType]["MCTCards"];
   this.getField("1ChTTechVal").value = PricingData[cPricingType]["1CT"];
   this.getField("IRTechVal").value = PricingData[cPricingType]["IR"];
   this.getField("IITechVal").value = PricingData[cPricingType]["IIController"];
   this.getField("CCReceiverTechVal").value = PricingData[cPricingType]["CCReceiver"];
   this.getField("CCServerTechVal").value = PricingData[cPricingType]["CCServer"];
   this.getField("1stHrTechVal").value = PricingData[cPricingType]["1stHour"];
   this.getField("AddlHrTechVal").value = PricingData[cPricingType]["AddlHour"];
   this.getField("MileageTechVal").value = PricingData[cPricingType]["Mileage"];
}

And here is the combo box script (also from the tutorial);

if( event.willCommit )
{
   if(event.value == "")     this.resetForm(["DefaultScreenTechVal","12CMOnlyTechVal","12wPTechVal","CsafeTechVal","NonCsafeTechVal","MCTTechVal","MCTCardsTechVal","1ChTTechVal","IRTechVal","IITechVal","CCReceiverTechVal","CCServerTechVal","1stHrTechVal","AddlHrTechVal","MileageTechVal"]);
   else
    SetFieldValues(event.value);
}

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Are you getting any error messages on the JavaScript console with your code when you try to select an item in the combo box?

I receive the following when I use your code and select the "Standard Price" or the empty selection:

Quote:
PricingData[cPricingType] has no properties
37:Document-Level:PricingData
PricingData[cPricingType] has no properties
37:Document-Level:PricingData
PricingData[cPricingType] has no properties
39:Document-Level:PricingData
PricingData[cPricingType] has no properties
39:Document-Level:PricingData
PricingData[cPricingType] has no properties
39:Document-Level:PricingData
PricingData[cPricingType] has no properties
39:Document-Level:PricingData
missing } after property list
18:
PricingData[cPricingType] has no properties
37:Document-Level:PricingData
PricingData[cPricingType] has no properties
37:Document-Level:PricingData
This implies that you have not properly defined the "Standard Price" element or you have not properly terminated the "New York Price" element.

The filled in items do not clear when the empty item is selected becuase one can not have an empty option for a combo box, it is either a space or some text.

George Kaiser

tehashi
Registered: Jun 30 2009
Posts: 20
Sorry about that, i had changed some names to see if i could get it to work. I changed them back to the previous iteration that did work except for my problem.

Here is the PDF of the form i am working on; [url=http://www.mediafire.com/?ynw5dwng3mc]Here[/url] Page 3 is the page with the pricing calculations.

I noticed that while the default value of the invisible text fields stays the standard price, the text in it was changed to new york price and does not change when testing the form out.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
I still get the JavaScript console errors!!!!

Again, are you getting any JavaScript console errors?

You have an initialization error creating your data object "PricingObject". Specifically, you have not terminated the "New York Pricing" element until after the "Standard Price" element, so there is no "Standard Price" element.

Your test for the 'empty' value is still looking for a null string. A combo box or list box does not accept a null string, it has to be at least a space.

Try the following code for the 'Custom keystroke' to illustrate the difference between an empty string value and a space string value:
if( event.willCommit ){// some debugging console.show(); console.clear();var character = ''; //create a null stringconsole.println('null string: |' + character + '| length: ' + character.length);character = ' '; // create a single space stringconsole.println('space string: |' + character + '| length: ' + character.length);console.println('event.value: |' + event.value + '| event value size: ' + event.value.length);// end debuggingif(event.value == "")     this.resetForm(["DefaultScreenTechVal","12CMOnlyTechVal","12wPEPTechVal","CsafeTechVal","NonCsafeTechVal","MCTTechVal","MCTCardsTechVal","1ChTTechVal","IRTechVal","PEPIITechVal","CCReceiverTechVal","CCServerTechVal","1stHrTechVal","AddlHrTechVal","MileageTechVal"]);elseSetFieldValues(event.value);}

George Kaiser

tehashi
Registered: Jun 30 2009
Posts: 20
I do not get any errors. I am using Acrobat pro 9, would that be causing you errors?

Also, I think i fixed it.

I corrected the issue with Standard not being an item so it should be now.
"Mileage": "0.95"},"Standard Price":{ "Screens": "87.50", and

 "Mileage": "0.95" }};

And i changed the null to a space in the combo box script so it counts the blank entry.

Thank you very much for your help.