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;
}
In other words, property names must be valid JavaScript identifiers or strings. To be safe, simply place quotes around them.
George