Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

420
Views
Dynamic Dropdown Menu using 'switch' Javascript Not Working

I have this script at the document level (simplified) on a PDF:

function SetFieldValues(){
var Model = this.getField("Model");
var Armor = this.getField("Armor");
var Winch = this.getField("Winch");
var Test1 = this.getField("Test1");
var Test2 = this.getField("Test2");

if(event.willCommit)    {
switch(event.value) {

case "015305676":
    Model.value = "AMK23";
    Armor.value = "YES";
    Winch.value = "NO";
    Test1.setItems[("Not Applicable")];
    Test2.setItems[("-", "Serviceable", "Unserviceable")];
    break;
}}}

This event is kicked off by the Custom Keystroke on the form's initiating dropdown list:

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

All the fields update appropriately (Model, Armor, and Winch) however, the "Test" combo boxes do not populate as expected.

I then tried it a different way with this (which I thought would be genius using an array ...pfft... I was wrong):

function SetFieldValues(){
var Model = this.getField("Model");
var Armor = this.getField("Armor");
var Winch = this.getField("Winch");

const ArmorArray = [field='Test1', field='Test2'];
var ArmorArray;

var CheckOptionsY = {
  Yes: [["-"],["Serviceable"],["Unserviceable"]],
};
var CheckOptionsN = {
  No: [["Not Applicable"]],
};
if(event.willCommit)
{
switch(event.value) {

case "015305676":
    Model.value = "AMK23";
    Armor.value = "YES";
    Winch.value = "NO";
    ArmorArray.setItems[(CheckOptionsY)];
    break;
}}}

Again, the fields update no problem (Model, Armor, and Winch) but the "Test" fields do not update with the combo box list options. What did I do wrong? How can I get these "Test" combo boxes to load with the appropriate 'Yes' / 'No' options?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!