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

automatic content based on choice of a previous Combo Box

triplequadrupole
Registered: May 11 2010
Posts: 4
Answered

I have a combo box with several options and I want to have a text field atomatically filled based on the choice in said Combo box. I've been trying the following and it does not work. Any ideas? Thanks
Triplequad

if (combo box1=='EB')
event.value = 65;
else
if (combo box1== 'TT')
event.value = 225;
else
if (combo box1== 'EB-SS')
event.value = 1000;

PS I'm trying this is in the 'Custom calculation script' of a text field box. I always get the message
"missing ) after condition
1: at Line 2"
...or something similar...

My Product Information:
Acrobat Standard 9.3.1, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You need to use the 'getField()' object of the documnet object and the value property of that object. Filed names are character strings and need to be within quotation marks.

var sName = 'combo box1'; // define field name valuevar oTest = this.getField(sName); // get the object for the 'combo box1' fieldvar sTest = oTest.value; // get the value of the test objectif (sTest == 'EB')event.value = 65;else if (sTest == 'TT')event.value = 225;else if (sTest == 'EB-SS')event.value = 1000;

You could also use the 'switch' statement for the decision code.
// using the 'combo box1' field value:switch(this.getField('combo box1').value) {case 'EB' :event.value = 65; // 'EB' choicebreak;case 'TT' :event.value = 225; // 'TT' choice break;case 'EB-SS' : // 'EB-SS' choiceevent.value = 1000;break;default: // unknown choiceevent.value = ''; // other code as necessarybreak;}

George Kaiser

triplequadrupole
Registered: May 11 2010
Posts: 4
THANK YOU! the first code worked perfectly!