11 Replies Latest reply on Nov 3, 2011 1:14 PM by rfarrugia

    syntax error in script to populate text field with drop-down menu

    rfarrugia

      Hi,

       

      I'm not a programmer, by any stretch of the imagination, but I need to populate a text field in my form depending on what the user chooses from a particular pull-down menu. After many searches, I did find a custom keystroke script which I adjusted to use my variables. However, the acrobat JS debugger is returning a syntax error about Exec being undefined. When I test the form, all I get is the word "undefined" popping up in the text field.

       

      I'm posting my script below. Is there a JS maven out there that can let me know what I'm missing? Or perhaps suggest a better script?

       

      Thanks in advance for your help!

      Ruth

       

      // Custom Keystroke script for combo box

      (function () {

       

       

      if (!event.willCommit) {

       

       

      // Set up an array of closure states based on gender/quantity.

      var astate = [];

      astate[0] = "seront fermées";

      astate[1] = "sera fermé";

      astate[2] = "sera fermée";

      astate[3] = "sera fermée";

      astate[4] = "sera fermée";

      astate[5] = "sera fermé";

      astate[6] = "sera fermé";

       

       

      // Associate export values of combo box items

      // to corresponding index of buildings

      var abuilding = [];

      abuilding[0] = "L’administration et la cour des travaux publics";

      abuilding[1] = "L’hôtel de ville";

      abuilding[2] = "L’administration du Service des loisirs";

      abuilding[3] = "L’aréna Samuel Moskovitch";

      abuilding[4] = "L’administration de l’Aréna Samuel Moskovitch";

      abuilding[5] = "Le gymnase";

      abuilding[6] = "Le Centre communautaire et aquatique";

       

       

      // Get the export value of the selected item

      var ex_val = event.changeEx;

       

       

      // Get the corresponding closure state

      var state = astate[abuilding[ex_val]];

       

       

      // Populate the text field with the closure state

      getField("TextField1").value = state;

      }

       

       

      })();