This tutorial demonstrates how to use JavaScript to allow the choice of one dropdown to affect the choices of another dropdown. The JavaScript “Switch” statement in the “exit” event of a dropdown is utilized to populate new choices in another dropdown. Essentially this create a “dynamic dropdown” in your dynamic pdf form.
Full Script:
// Basic Structure of a JavaScript Switch Statment
cboModel.clearItems();
switch(this.rawValue){
case “1”:
cboModel.addItem(“CL”);
cboModel.addItem(“CSX”);
cboModel.addItem(“EL”);
cboModel.addItem(“Integra”);
cboModel.addItem(“Legend”);
cboModel.addItem(“MDX”);
cboModel.addItem(“NSX”);
cboModel.addItem(“RDX”);
cboModel.addItem(“RL”);
cboModel.addItem(“RSX”);
cboModel.addItem(“SLX”);
cboModel.addItem(“TL”);
cboModel.addItem(“TSX”);
cboModel.addItem(“Vigor”);
break;
case “2”:
cboModel.addItem(“CL”);
cboModel.addItem(“A3”);
cboModel.addItem(“A4”);
cboModel.addItem(“A5”);
cboModel.addItem(“A6”);
cboModel.addItem(“AS”);
cboModel.addItem(“Cabriolet”);
cboModel.addItem(“Fox”);
cboModel.addItem(“Q7”);
cboModel.addItem(“R8”);
cboModel.addItem(“RS4”);
cboModel.addItem(“RS6”);
cboModel.addItem(“S4”);
cboModel.addItem(“S5”);
cboModel.addItem(“S6”);
cboModel.addItem(“SS”);
cboModel.addItem(“Super 90”);
cboModel.addItem(“TT”);
cboModel.addItem(“V8 Quattro”);
break;
case “3”:
cboModel.addItem(“318i”);
cboModel.addItem(“320i”);
cboModel.addItem(“323i”);
cboModel.addItem(“325e”);
cboModel.addItem(“325i”);
cboModel.addItem(“328i”);
cboModel.addItem(“330i”);
cboModel.addItem(“335i”);
cboModel.addItem(“3501”);
cboModel.addItem(“523i”);
cboModel.addItem(“524TD”);
cboModel.addItem(“525i”);
cboModel.addItem(“528e”);
cboModel.addItem(“5301”);
cboModel.addItem(“533i”);
cboModel.addItem(“535i”);
cboModel.addItem(“540i”);
cboModel.addItem(“545i”);
cboModel.addItem(“550i”);
cboModel.addItem(“630CSi”);
cboModel.addItem(“635CSi”);
cboModel.addItem(“640SCi”);
cboModel.addItem(“650i”);
cboModel.addItem(“723”);
cboModel.addItem(“732”);
cboModel.addItem(“733i”);
cboModel.addItem(“735i”);
cboModel.addItem(“740i”);
cboModel.addItem(“745i”);
cboModel.addItem(“750i”);
cboModel.addItem(“760i”);
cboModel.addItem(“840i”);
break;
case “4”:
cboModel.addItem(“Prism”);
cboModel.addItem(“Storm”);
cboModel.addItem(“Tracker”);
break;
case “5”:
cboModel.addItem(“Honda Accord”);
cboModel.addItem(“Honda Accord EX”);
cboModel.addItem(“Honda Accord LX”);
cboModel.addItem(“Honda Accord LXI”);
cboModel.addItem(“Honda Civic”);
cboModel.addItem(“Honda Civic DX”);
cboModel.addItem(“Honda Civic EX”);
cboModel.addItem(“Honda Civic HF”);
cboModel.addItem(“Honda Civic HX”);
cboModel.addItem(“Honda Civic LX”);
cboModel.addItem(“Honda CRV”);
cboModel.addItem(“Honda CRV EX”);
cboModel.addItem(“Honda CRV LX”);
cboModel.addItem(“Honda CRX”);
cboModel.addItem(“Honda Del Sol”);
cboModel.addItem(“Honda Element”);
cboModel.addItem(“Honda FCX”);
cboModel.addItem(“Honda Fit”);
cboModel.addItem(“Honda Insight”);
cboModel.addItem(“Honda Odyssey”);
cboModel.addItem(“Honda Passport”);
cboModel.addItem(“Honda Pilot”);
cboModel.addItem(“Honda Prelude”);
cboModel.addItem(“Honda Ridgeline”);
cboModel.addItem(“Honda S2000”);
break;
case “6”:
cboModel.addItem(“Hyundai Azera”);
cboModel.addItem(“Hyundai Elantra”);
cboModel.addItem(“Hyundai Entourage”);
cboModel.addItem(“Hyundai Excel”);
cboModel.addItem(“Hyundai Pony”);
cboModel.addItem(“Hyundai Santa Fe”);
cboModel.addItem(“Hyundai Scoupe”);
cboModel.addItem(“Hyundai Sonata”);
cboModel.addItem(“Hyundai Stellar”);
cboModel.addItem(“Hyundai Tiburon”);
cboModel.addItem(“Hyundai Tucson”);
cboModel.addItem(“Hyundai Veracruz”);
cboModel.addItem(“Hyundai XG Series”);
break;
case “7”:
cboModel.addItem(“i30”);
cboModel.addItem(“i35”);
cboModel.addItem(“i36”);
cboModel.addItem(“FX”);
cboModel.addItem(“G20”);
cboModel.addItem(“G35”);
cboModel.addItem(“G37”);
cboModel.addItem(“J30”);
cboModel.addItem(“M30”);
cboModel.addItem(“M35”);
cboModel.addItem(“M45”);
cboModel.addItem(“Q45”);
cboModel.addItem(“QX4”);
cboModel.addItem(“QX56”);
break;
case “8”:
cboModel.addItem(“Amigo”);
cboModel.addItem(“Ascender”);
cboModel.addItem(“Axiom”);
cboModel.addItem(“Gemini”);
cboModel.addItem(“Hombre”);
cboModel.addItem(“IMark”);
cboModel.addItem(“Impulse”);
cboModel.addItem(“Oasis”);
cboModel.addItem(“Optima”);
cboModel.addItem(“Rodeo”);
cboModel.addItem(“Stylus”);
cboModel.addItem(“Trooper/Trooper II”);
cboModel.addItem(“Truck “);
cboModel.addItem(“Vehicross”);
break;
case “9”:
cboModel.addItem(“Amanti”);
cboModel.addItem(“Magentis”);
cboModel.addItem(“Rio”);
cboModel.addItem(“Rondo”);
cboModel.addItem(“Sedona”);
cboModel.addItem(“Sephia”);
cboModel.addItem(“Sorento”);
cboModel.addItem(“Spectra”);
cboModel.addItem(“Sportage”);
break;
case “10”:
cboModel.addItem(“250ES”);
cboModel.addItem(“ES300”);
cboModel.addItem(“ES330”);
cboModel.addItem(“ES350”);
cboModel.addItem(“GS300”);
cboModel.addItem(“GS350”);
cboModel.addItem(“GS400”);
cboModel.addItem(“GS450”);
cboModel.addItem(“GS460”);
cboModel.addItem(“GX470”);
cboModel.addItem(“LS400”);
cboModel.addItem(“LS430”);
cboModel.addItem(“LS460”);
cboModel.addItem(“LS600 Hybrid”);
cboModel.addItem(“LX470”);
cboModel.addItem(“LX450”);
cboModel.addItem(“RX300”);
cboModel.addItem(“RX330”);
cboModel.addItem(“RX350”);
cboModel.addItem(“RX400 Hybrid”);
cboModel.addItem(“SC (excl 430)”);
cboModel.addItem(“SC430”);
cboModel.addItem(“IS250”);
cboModel.addItem(“IS300”);
cboModel.addItem(“IS350”);
break;
case “11”:
cboModel.addItem(“3”);
cboModel.addItem(“323”);
cboModel.addItem(“5”);
cboModel.addItem(“6”);
cboModel.addItem(“626”);
cboModel.addItem(“808”);
cboModel.addItem(“929”);
cboModel.addItem(“Cosmo”);
cboModel.addItem(“CX7”);
cboModel.addItem(“CX9”);
cboModel.addItem(“GLC”);
cboModel.addItem(“Miata MX5”);
cboModel.addItem(“Millenia”);
cboModel.addItem(“MPV”);
cboModel.addItem(“MX3”);
cboModel.addItem(“MX6”);
cboModel.addItem(“Navajo”);
cboModel.addItem(“Pickup-B1600”);
cboModel.addItem(“Pickup-B1800”);
cboModel.addItem(“Pickup-B2000”);
cboModel.addItem(“Pickup-B2200”);
cboModel.addItem(“Pickup-B2300”);
cboModel.addItem(“Pickup-B2500”);
cboModel.addItem(“Pickup-B2600”);
cboModel.addItem(“Pickup-B3000”);
cboModel.addItem(“Pickup-B4000”);
cboModel.addItem(“Pickup-Rotary”);
cboModel.addItem(“Protege”);
cboModel.addItem(“RX8”);
cboModel.addItem(“Tribute”);
break;
case “12”:
cboModel.addItem(“170”);
cboModel.addItem(“190”);
cboModel.addItem(“200”);
cboModel.addItem(“218”);
cboModel.addItem(“219”);
cboModel.addItem(“220”);
cboModel.addItem(“230”);
cboModel.addItem(“230-4 Cyl”);
cboModel.addItem(“230-6 Cal”);
cboModel.addItem(“240D”);
cboModel.addItem(“250”);
cboModel.addItem(“260E”);
cboModel.addItem(“300CD”);
cboModel.addItem(“300D “);
cboModel.addItem(“300E”);
cboModel.addItem(“300SD”);
cboModel.addItem(“300SL”);
cboModel.addItem(“300TD”);
cboModel.addItem(“320”);
cboModel.addItem(“350”);
cboModel.addItem(“380”);
cboModel.addItem(“400”);
cboModel.addItem(“420”);
cboModel.addItem(“450”);
cboModel.addItem(“500”);
cboModel.addItem(“560”);
cboModel.addItem(“600”);
cboModel.addItem(“B Class”);
cboModel.addItem(“C Class”);
cboModel.addItem(“CL Class”);
cboModel.addItem(“CLK”);
cboModel.addItem(“CLS”);
cboModel.addItem(“E Class”);
cboModel.addItem(“E55”);
cboModel.addItem(“G Class”);
cboModel.addItem(“GL Class”);
cboModel.addItem(“ML Series”);
cboModel.addItem(“R Class”);
cboModel.addItem(“S Class”);
cboModel.addItem(“SLK”);
cboModel.addItem(“SLR”);
break;
case “13”:
cboModel.addItem(“Cooper”);
cboModel.addItem(“Cooper Convertible”);
cboModel.addItem(“Cooper S”);
cboModel.addItem(“Cooper S Convertible”);
cboModel.addItem(“Cooper Clubman”);
break;
case “14”:
cboModel.addItem(“3000”);
cboModel.addItem(“Diamante”);
cboModel.addItem(“Eclipse”);
cboModel.addItem(“Endeavor”);
cboModel.addItem(“Expo”);
cboModel.addItem(“Fuso”);
cboModel.addItem(“Galant”);
cboModel.addItem(“Lancer”);
cboModel.addItem(“Mirage”);
cboModel.addItem(“Montero”);
cboModel.addItem(“Montero-Sport”);
cboModel.addItem(“Outlander”);
cboModel.addItem(“Pickup “);
cboModel.addItem(“Precis”);
cboModel.addItem(“Sigma”);
cboModel.addItem(“Tredia”);
cboModel.addItem(“Van”);
break;
case “15”:
cboModel.addItem(“300ZX”);
cboModel.addItem(“710”);
cboModel.addItem(“Access”);
cboModel.addItem(“Almera”);
cboModel.addItem(“Altima”);
cboModel.addItem(“Armada”);
cboModel.addItem(“F10”);
cboModel.addItem(“Frontier”);
cboModel.addItem(“Lucino”);
cboModel.addItem(“Maxima “);
cboModel.addItem(“Micra”);
cboModel.addItem(“Murano”);
cboModel.addItem(“NX”);
cboModel.addItem(“Pathfinder”);
cboModel.addItem(“Patrol”);
cboModel.addItem(“Plating”);
cboModel.addItem(“Pulsar”);
cboModel.addItem(“Quest”);
cboModel.addItem(“Rogue”);
cboModel.addItem(“Sentra”);
cboModel.addItem(“Stanza “);
cboModel.addItem(“Stanza Van”);
cboModel.addItem(“Tida”);
cboModel.addItem(“Truck”);
cboModel.addItem(“Truck-Titan”);
cboModel.addItem(“Versa”);
cboModel.addItem(“X Trail”);
cboModel.addItem(“Xterra”);
break;
case “16”:
cboModel.addItem(“356”);
cboModel.addItem(“911/930”);
cboModel.addItem(“912/e”);
cboModel.addItem(“914”);
cboModel.addItem(“924”);
cboModel.addItem(“928”);
cboModel.addItem(“944”);
cboModel.addItem(“968”);
cboModel.addItem(“Boxster”);
cboModel.addItem(“Carrera-GT”);
cboModel.addItem(“Cayenne”);
cboModel.addItem(“Cayman S”);
break;
case “17”:
cboModel.addItem(“9-3”);
cboModel.addItem(“9-3 Convertible”);
cboModel.addItem(“9-5 “);
cboModel.addItem(“9-5 Convertible”);
cboModel.addItem(“900”);
cboModel.addItem(“900 Convertible”);
cboModel.addItem(“900 S”);
cboModel.addItem(“900 SE”);
cboModel.addItem(“900 SE Convertible”);
break;
case “18”:
cboModel.addItem(“tC”);
cboModel.addItem(“x8”);
cboModel.addItem(“xA”);
cboModel.addItem(“xD”);
break;
case “19”:
cboModel.addItem(“Baja”);
cboModel.addItem(“Brat”);
cboModel.addItem(“Forester”);
cboModel.addItem(“Impreza”);
cboModel.addItem(“Justy”);
cboModel.addItem(“Legacy”);
cboModel.addItem(“SVX”);
cboModel.addItem(“Tribeca”);
cboModel.addItem(“XT”);
break;
case “20”:
cboModel.addItem(“Aerio”);
cboModel.addItem(“Esteem”);
cboModel.addItem(“Forenza”);
cboModel.addItem(“Forsa”);
cboModel.addItem(“Reno”);
cboModel.addItem(“Samurai”);
cboModel.addItem(“Sidekick”);
cboModel.addItem(“SJ410”);
cboModel.addItem(“SM”);
cboModel.addItem(“Swift”);
cboModel.addItem(“Verona”);
cboModel.addItem(“Vitara”);
cboModel.addItem(“X90”);
cboModel.addItem(“XL7”);
break;
case “21”:
cboModel.addItem(“4Runner”);
cboModel.addItem(“Avalon”);
cboModel.addItem(“Camry”);
cboModel.addItem(“Camry Hybrid”);
cboModel.addItem(“Camry LE”);
cboModel.addItem(“Camry SE”);
cboModel.addItem(“Camry XLE”);
cboModel.addItem(“Camry-Solara”);
cboModel.addItem(“Celica”);
cboModel.addItem(“Celica GT”);
cboModel.addItem(“Celica Convertible”);
cboModel.addItem(“Corolla FX/FX16”);
cboModel.addItem(“Corolla”);
cboModel.addItem(“Echo”);
cboModel.addItem(“FJ Cruiser”);
cboModel.addItem(“FX/FX 16”);
cboModel.addItem(“Highlander”);
cboModel.addItem(“Land Cruiser”);
cboModel.addItem(“Matrix”);
cboModel.addItem(“MR2”);
cboModel.addItem(“Paseo”);
cboModel.addItem(“Previa”);
cboModel.addItem(“Prius”);
cboModel.addItem(“RAV4”);
cboModel.addItem(“Sequoia”);
cboModel.addItem(“Sienna”);
cboModel.addItem(“Solara”);
cboModel.addItem(“Supra”);
cboModel.addItem(“T100”);
cboModel.addItem(“Tacoma”);
cboModel.addItem(“Tercel”);
cboModel.addItem(“Truck”);
cboModel.addItem(“Tundra”);
cboModel.addItem(“Van”);
cboModel.addItem(“Yaris”);
break;
case “22”:
cboModel.addItem(“Cabriolet”);
cboModel.addItem(“Corrado”);
cboModel.addItem(“Golf”);
cboModel.addItem(“Jetta”);
cboModel.addItem(“New Beetle”);
cboModel.addItem(“Passat”);
cboModel.addItem(“Phaeton”);
cboModel.addItem(“Touareg”);
cboModel.addItem(“Van-EuroVan”);
break;
case “23”:
cboModel.addItem(“240”);
cboModel.addItem(“240 Wagon”);
cboModel.addItem(“260”);
cboModel.addItem(“740”);
cboModel.addItem(“760”);
cboModel.addItem(“780”);
cboModel.addItem(“850”);
cboModel.addItem(“940”);
cboModel.addItem(“960”);
cboModel.addItem(“S60”);
cboModel.addItem(“V70 AWD”);
cboModel.addItem(“XC90”);
cboModel.addItem(“XC60”);
cboModel.addItem(“XC70”);
cboModel.addItem(“V70”);
cboModel.addItem(“V50”);
cboModel.addItem(“S40”);
cboModel.addItem(“S80”);
cboModel.addItem(“C30”);
cboModel.addItem(“C70”);
break;
default:
cboModel.addItem(“Please re-choose Make.”);
break;
}