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

combo box pre-pop'ing text fields... error message???

TadHogan
Registered: Jan 20 2009
Posts: 23
Answered

I put the following script into Document JavaScripts,... but it gives me this error message (missing : after property id 1: at line 3) and highlights everything for John Doe up thru the comma after his mobile#. Please comment. Thanks.

// Place all prepopulation data into a single data structure

var salespersonData = { John Doe - VCI:{ email: "john [at] vci [dot] com", address: "123 Main St. Newtown, PA 12345", phone: "610-222-3333", mobile: "443-222-3333" },
Bob Smith - A&M:{ email: "bob@A&M.com", address: "999 Nine St. New York, NY 21212", phone: "212-111-2222", mobile: "443-212-1212" },
Jane Doe - Monmouth:{ email: "jane [at] monmouth [dot] com", address: "44 Forty Rd. Fours, NJ 21321", phone: "111-111-1111", mobile: "443-777-7777" },
Sally Jones - Bussani:{ email: "sally [at] bussani [dot] com", address: "555 Fifty Ave. Fives, CT 06511", phone: "203-203-2032", mobile: "443-443-4434" }};

function SetFieldValues(csalesperson)
{
this.getField("email").value = salespersonData[csalesperson].email;

this.getField("address").value = salespersonData[csalesperson].address;

this.getField("phone").value = salespersonData[csalesperson].phone;

this.getField("mobile").value = salespersonData[csalesperson].mobile;
}

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Try this:

var salespersonData = { "John Doe - VCI" : {email : "<span class="spamspan"><span class="u">john</span> [at] <span class="d">vci [dot] com</span></span>",address: "123 Main St. Newtown, PA 12345",phone: "610-222-3333",mobile: "443-222-3333"}, "Bob Smith - A&M" : {email : "bob@A&M.com",address : "999 Nine St. New York, NY 21212",phone : "212-111-2222",mobile : "443-212-1212"}, "Jane Doe - Monmouth" : {email : "<span class="spamspan"><span class="u">jane</span> [at] <span class="d">monmouth [dot] com</span></span>",address : "44 Forty Rd. Fours, NJ 21321",phone : "111-111-1111",mobile : "443-777-7777"}, "Sally Jones - Bussani" : {email : "<span class="spamspan"><span class="u">sally</span> [at] <span class="d">bussani [dot] com</span></span>",address : "555 Fifty Ave. Fives, CT 06511",phone : "203-203-2032",mobile : "443-443-4434"}};

In other words, property names must be valid JavaScript identifiers or strings. To be safe, simply place quotes around them.

George
TadHogan
Registered: Jan 20 2009
Posts: 23
Thank you, George Johnson. It worked!
TadHogan
Registered: Jan 20 2009
Posts: 23
Again, for another combo box, I'm trying to pre-pop other fields with the selection chosen (using the salesperson code as a model with "quotes", etc.), but the Document Javascript isn't taking my code (see below... I called it SetFieldValues_2) and it's giving me that error message again (missing : after property id...). Please comment. Thank you.

var top_packageData = {

"18-inch Sport Top Paratransit Package - Standard" : {
PM.2_top: "1",
PM.25_top: "2",
PM.27_top: "3",
PM.29_top: "4",
PM.31_top: "5",
PM.33_top: "6",
PM.35_top: "7",
PM.37_top: "8",
PM.39_top: "9",
PM.41_top: "10",
PM.43_top: "11"
},

"18-inch Sport Top Paratransit Package - Extended" : {
PM.2_top: "12",
PM.25_top: "13",
PM.27_top: "14",
PM.29_top: "15",
PM.31_top: "16",
PM.33_top: "17",
PM.35_top: "18",
PM.37_top: "19",
PM.39_top: "20",
PM.41_top: "21",
PM.43_top: "22"
},

"16-inch Mid Top Paratransit Package - Standard" : {
PM.2_top: "23",
PM.25_top: "24",
PM.27_top: "25",
PM.29_top: "26",
PM.31_top: "27",
PM.33_top: "28",
PM.35_top: "29",
PM.37_top: "30",
PM.39_top: "31",
PM.41_top: "32",
PM.43_top: "33"
},

"16-inch Mid Top Paratransit Package - Extended" : {
PM.2_top: "34",
PM.25_top: "35",
PM.27_top: "36",
PM.29_top: "37",
PM.31_top: "38",
PM.33_top: "39",
PM.35_top: "40",
PM.37_top: "41",
PM.39_top: "42",
PM.41_top: "43",
PM.43_top: "44"
},

"24-inch Camper Top Paratransit Package - Standard" : {
PM.2_top: "45",
PM.25_top: "46",
PM.27_top: "47",
PM.29_top: "48",
PM.31_top: "49",
PM.33_top: "50",
PM.35_top: "51",
PM.37_top: "52",
PM.39_top: "53",
PM.41_top: "54",
PM.43_top: "55"
},

"24-inch Camper Top Paratransit Package - Extended" : {
PM.2_top: "56",
PM.25_top: "57",
PM.27_top: "58",
PM.29_top: "59",
PM.31_top: "60",
PM.33_top: "61",
PM.35_top: "62",
PM.37_top: "63",
PM.39_top: "64",
PM.41_top: "65",
PM.43_top: "66"
},

"32-inch Transit Top Paratransit Package - Extended" : {
PM.2_top: "67",
PM.25_top: "68",
PM.27_top: "69",
PM.29_top: "70",
PM.31_top: "71",
PM.33_top: "72",
PM.35_top: "73",
PM.37_top: "74",
PM.39_top: "75",
PM.41_top: "76",
PM.43_top: "77"
}
};

function SetFieldValues_2(ctop_package)
{
this.getField("PM.2_top").value = top_packageData[ctop_package].PM.2_top;

this.getField("PM.43_top").value = top_packageData[ctop_package].PM.43_top;
}
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Place quotes around your property names:

    "PM.2_top" : "1","PM.25_top" : "2","PM.27_top" : "3",// Etc.

George
TadHogan
Registered: Jan 20 2009
Posts: 23
Thanks, but now it's a different error message with a lower section highlighed. It now says "missing ; before statement 104" with this highlighted, prob statement 104:

this.getField("PM.25_top").value = top_packageData[ctop_package].PM.25_top;

All I can think of is to add quotes around the field name at the end ??
TadHogan
Registered: Jan 20 2009
Posts: 23
I added quotes around field name at end (see above) and now the error message says "missing name after . operator"... also at same place. Thanks.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Do this:

this.getField("PM.25_top").value = top_packageData[ctop_package]["PM.25_top"];
And consider getting this: http://oreilly.com/catalog/9780596101992/

;^)


George
TadHogan
Registered: Jan 20 2009
Posts: 23
It was accepted. Thanks for your responses.