简体   繁体   中英

Adobe Acrobat: Changing Another Field with Combo Box (Drop Down) Selection

I created a PDF for our machine maintenance program. I need the drop down (combo box) to auto fill two other sections. The drop down box this the Machine ID (POCO). When I select a POCO from the drop down, I want it to auto fill the Model and Serial text boxes. I followed this tutorial https://acrobatusers.com/tutorials/change_another_field But I keep getting syntax errors. My combo box custom keystroke script contains this:

if( event.willCommit ) { 
if(event.value == "") this.resetForm(["Model","Serial"]); else SetFieldValues(event.value); 
}

My Javascript contains this:

// Place all pre-population data into a single data structure 
var POCO = { 5905-16:{ Model: "VMC 40", Serial: "9502956"}, 5905-13:{ Model: "VMC 40", Serial: "8803280"}, 5905-17 :{ Model: "4020", Serial: "8704778"}, 5905-30:{ Model: "6030", Serial: "12000101549"}, 5905-18 :{ Model: "8030", Serial: "9705016"}, 5905-22 :{ Model: "4020", Serial: "8803275"}, 5905-14 :{ Model: "VMC 40", Serial: "891819"}, 5905-15 :{ Model: "VMC 40", Serial: "9502954"}, 5905-23 :{ Model: "4020", Serial: "9910369"}, 5905-10 :{ Model: "VMC 40", Serial: "8803280"}, 5905-11 :{ Model: "4020", Serial: "8912817"}, 5905-20 :{ Model: "4020", Serial: "9801177"}, 5905-28 :{ Model: "VMC 40", Serial: "9101912"}, 5905-29 :{ Model: "4020", Serial: "9807346"}, 5905-12 :{ Model: "4020", Serial: "8912818"}, 5905-19 :{ Model: "6030", Serial: "9709227"}, 5905-24 :{ Model: "6030", Serial: "9910370"}, 5905-21 :{ Model: "4020", Serial: "9801176"}, 5905-34 :{ Model: "VMC 4020 HT", Serial: "32004066433"}, 5905-33 :{ Model: "VMC 4020 HT", Serial: "32004086742"}}; 
function SetFieldValues(cDeptName) { 
// Populate fields with values from the Department Data Object 
this.getField(“Model”).value = POCO[cDeptName].Model; 
this.getField(“Serial”).value = POCO[cDeptName].Serial;  
}

Im very new to this so I am sure there are novice mistakes made. I appreciate any input.

POCO哈希中的键应全部为字符串,因此用引号引起来。

  var POCO = { "5905-16":{ "Model": "VMC 40", "Serial": "9502956"}, ...} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM