Acrobat User Community Forums

You are not logged in.     Log in to your AUC account.     Don't have an account? Sign up today

#1 2008-01-10 14:46:24

Meabh
Member
Registered: 2007-05-17
Posts: 5

Dropdown box script

Got this script off the Acrobat User Community courtesy of Thom Parker. I can adjust it to do what I need but it doesn't allow a bar space in the name of the dropdown option. In the script its 'Accounting' that I need to change to District Court but the error message is "Missing : after property id"

Here's Thoms script:

// Place all prepopulation data into a single data structure
var DeptData = { Accounting:{ contact: "Court Name",
                              email: "Address ",
                              deptnum1: "address2",
                              deptnum2: "city, state, zip" }};
function SetFieldValues(cDeptName)
{
  this.getField("DeptContact").value = DeptData[cDeptName].contact;
  this.getField("DeptEmail").value = DeptData[cDeptName].email;
  this.getField("DeptNumber1").value = DeptData[cDeptName].deptnum1;
  this.getField("DeptNumber2").value = DeptData[cDeptName].deptnum2;
}

This is the link to the complete article -
[link=http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/change_another_field/]http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/change_another_field/[/link]

Any thoughts?
Meabh


My Product Information:
Acrobat Pro 7 / Windows

Offline

 

#2 2008-01-14 17:08:36

thomp
Member

Registered: 2007-04-23
Posts: 860

Re: Dropdown box script

I believe you are have trouble with the "DeptData" object.  Generally object property names do not contain special characters becaused they are used like variable names.  However, and it's not the best programming practice, you can place quotes around property names that contain characters like spaces. 

EX:

var DeptData = { "District Court":{ contact: "Court Name",
email: "Address ",
deptnum1: "address2",
deptnum2: "city, state, zip" }};

To uses this property name you have to use the array notation for acessing the object property.

var deptEmail = DeptData["District Court"].email;

Offline

 

#3 2008-02-19 13:01:58

clotte
Member
Registered: 2008-02-14
Posts: 5

Re: Dropdown box script

I'm working on a similar project. I amhaving the same problem: missing: after property id.

question for thomp:
where does  "var deptEmail = DeptData["District Court"].email;" go?

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

AcrobatUsers.com  >>  User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in