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

Adobe Acrobat 9- Custom Java Script made to autopopulate Text Fields from A Drop Down list Not working

leyva33
Registered: Mar 28 2011
Posts: 3

Hello- I really need some help. I created a script to auto-populate some text fields from the drop down selection that is chosen. The script was accepted but will not work. Is there something I did incorrectly. The script is listed below:
 
//Place all pre-populated data into a structure var servicedata={Activation Only:{subone:"Device Model",subtwo:"SIM/IMEI/MSN/DEC/MEID",subthree: "Username"},Cancellation:{subone:"Existing Phone Number",subtwo:"Reason for Cancellation"},Feature Change:{subone:"Existing Phone Number",subtwo:"What change is needed?"},New Line/Phone Order:{subone:"Device Model/Type",subtwo:"Shipping Address"},Port Order:{subone:"Current Account Number",subtwo:"Device Model/Type",subthree:"Existing Phone Number",subfour:"Shipping Address",subfive:"What is needed?",subsix:"If new phone is needed, which one?"},Swap:{subone: "Existing Phone Number",subtwo: "SIM/IMEI/MSN/DEC/MEID",subthree: "What type of new phone did you receive?"},Transfer of Liability :{ subone: "AOL/TOL Form filled out and attached Yes or No?",subtwo:"Existing Phone Number",subthree:"Current Account Number",subfour:"Please list new account number and carrier to Transfer to"},Upgrade Order:{subone:"Device Model/Type",subtwo:"Existing Phone Number",subthree:"Shipping Address",subfour:"What phone do you need?",subfive: "Other information"},Warranty Replacement:{subone: "Device Model/Type",subtwo:"Existing Phone Number",subthree:"Phone problem",subfour:"Shipping Address"}};
function SetFieldValues(cservselect)
{
//Populate Fields with values from the Service Data Object
this.getfield("sub1").value = servicedata[cservselect].subone;
this.getfield("sub2").value = servicedata[cservselect].subtwo;
this.getfield("sub3").value = servicedata[cservselect].subthree;
this.getfield("sub4").value = servicedata[cservselect].subfour;
this.getfield("sub5").value = servicedata[cservselect].subfive;
this.getfield("sub6").value = servicedata[cservselect].subsix;
this.getfield("sub7").value = servicedata[cservselect].subseven;
this.getfield("sub8").value = servicedata[cservselect].subeight;
}

My Product Information:
Acrobat Pro 9.3, Windows
leyva33
Registered: Mar 28 2011
Posts: 3
I have revised my code but still cannot get the script to run. It is accepted but doesn't work. I have a keystroke trigger as well which is the first part of my code which is setup in the Format, Custom Keystroke scrpt in the Combo Box Property.

if( event.willCommit ) { if(event.value == "") this.resetForm(["sub1","sub2","sub3","sub4","sub5","sub6","sub7","sub8"]); else SetFieldValues(event.value); }




function SetFieldValues()
{//Place all pre-populated data into a structure var servicedata={Activation Only:{subone:"Device Model",subtwo:"SIM/IMEI/MSN/DEC/MEID",subthree: "Username"},Cancellation:{subone:"Existing Phone Number",subtwo:"Reason for Cancellation"},Feature Change:{subone:"Existing Phone Number",subtwo:"What change is needed?"},New Line/Phone Order:{subone:"Device Model/Type",subtwo:"Shipping Address"},Port Order:{subone:"Current Account Number",subtwo:"Device Model/Type",subthree:"Existing Phone Number",subfour:"Shipping Address",subfive:"What is needed?",subsix:"If new phone is needed, which one?"},Swap:{subone: "Existing Phone Number",subtwo: "SIM/IMEI/MSN/DEC/MEID",subthree: "What type of new phone did you receive?"},Transfer of Liability :{ subone: "AOL/TOL Form filled out and attached Yes or No?",subtwo:"Existing Phone Number",subthree:"Current Account Number",subfour:"Please list new account number and carrier to Transfer to"},Upgrade Order:{subone:"Device Model/Type",subtwo:"Existing Phone Number",subthree:"Shipping Address",subfour:"What phone do you need?",subfive: "Other information"},Warranty Replacement:{subone: "Device Model/Type",subtwo:"Existing Phone Number",subthree:"Phone problem",subfour:"Shipping Address"}};

function SetFieldValues(serviceselect)
{//Populate Fields with values from the Service Data Object
this.getField("sub1").value = servicedata[serviceselect].subone;
this.getField("sub2").value = servicedata[serviceselect].subtwo;
this.getField("sub3").value = servicedata[serviceselect].subthree;
this.getField("sub4").value = servicedata[serviceselect].subfour;
this.getField("sub5").value = servicedata[serviceselect].subfive;
this.getField("sub6").value = servicedata[serviceselect].subsix;
this.getField("sub7").value = servicedata[serviceselect].subseven;
this.getField("sub8").value = servicedata[serviceselect].subeight;
}

}

leyva33
Registered: Mar 28 2011
Posts: 3
I used the debugger when I make a drop down selection from my code and this is what I get back:


servicedata is not defined
5:AcroForm:serviceselect:KeystrokeException in line 5 of function SetFieldValues, script Document-Level:SetFieldValues
Exception in line 1 of function top_level, script AcroForm:serviceselect:Keystroke

servicedata is not defined
5:AcroForm:serviceselect:Keystroke