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

auto populated third field based on second field

dbertanjoli
Registered: Nov 18 2007
Posts: 30

Hello, I would greatly appreciate reply to the following question.
I have a combo box, based on the selection of this combo box a text field is auto populated. Now, what I want to do is when this text is auto populated there is another co-depended text field to be auto populated.
  
I am using the following code:
 
On my first text field:
Custom keystroke script:
 
if( event.willCommit )
{
if(event.value == " ")
this.resetForm(["results"]);
else
SetFieldValues(event.value);
}
 
And this javascript function:
 
{
 
// Place all prepopulation data into a single data structure
var DeptData = { "Within 1 week":{ results: "IIa"},
 
"Within 3 months":{ results: "IV"},
 
"Within 3 weeks" :{ results: "IIb"},
 
"Within 6 weeks":{ results: "III"}};
function SetFieldValues(cDeptName)
{
this.getField("results").value = DeptData[cDeptName].results;
 

}}
 
my e-mail is: [link=mailto:dbertanjoli [at] cw [dot] bc [dot] ca]dbertanjoli [at] cw [dot] bc [dot] ca[/link]
 
Many thanks,
Deb

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This looks fine so far. Add the code for populating the second text field immediatly after the line of code that populates the first text feild. i.e., do them both at the same time.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

dbertanjoli
Registered: Nov 18 2007
Posts: 30
Many thanks Thom. I would like to add one more feature to this form. I would like, when someone select (other) from my combo box for a comment field to pop up (for additional explanation) and I would like this comment to be saved.

Can this be done?

Many thanks,
Deb