4 Replies Latest reply on Nov 13, 2009 4:19 PM by try67

    Need guidance for a Combo Box and Keystoke/Validate script

    mmrm Level 1

      Hello,

       

      My goal is to have a combo box selection trigger and enter a value into a text field however the text field needs to be editable.  I want the combo box to determine a default value but changeable by the user if necessary.  Here is the script, I just don't know where to put it.

       

      if (!event.willCommit) {

       

      var M1Month = this.getField("Month 1 Pulldown").value; var M1Exp = this.getField("M1 Exp");

      if(M1Month == "January") {M1Exp.value = "1/31/10"};

      if(M1Month == "February") {M1Exp.value = "2/28/10"};

      if(M1Month == "March") {M1Exp.value = "3/31/10"};

      if(M1Month == "April") {M1Exp.value = "4/30/10"};

      if(M1Month == "May") {M1Exp.value = "5/31/10"};

      if(M1Month == "June") {M1Exp.value = "6/30/10"};

      if(M1Month == "July") {M1Exp.value = "7/31/10"};

      if(M1Month == "August") {M1Exp.value = "8/31/10"};

      if(M1Month == "September") {M1Exp.value = "9/30/10"};

      if(M1Month == "October") {M1Exp.value = "10/31/10"};

      if(M1Month == "November") {M1Exp.value = "11/30/10"};

      if(M1Month == "December") {M1Exp.value = "12/31/10"};

      if(M1Month == " ") {M1Exp.value = ""};

       

      }

        • 1. Re: Need guidance for a Combo Box and Keystoke/Validate script
          gkaiseril MVP & Adobe Community Professional

          Combo boxes do not support the 'null' string, it is a space.

          • 2. Re: Need guidance for a Combo Box and Keystoke/Validate script
            mmrm Level 1

            G, thanks for the response but even if I take that line out I am still having problems.  I put the script in the custom keystroke but the action doesn't take place until I make a 2nd change to the combo box.  For example if I select "January" in the combo box nothing happens in field "M1 Exp", if I then go back and now select a different value say "March" then field "M1 Exp" changes to "1/31/10" and so on.

            • 3. Re: Need guidance for a Combo Box and Keystoke/Validate script
              gkaiseril MVP & Adobe Community Professional

              I did not say to take out the line. You need to replace the "" (a null string),  with " " (a space).

               

              But I would look at using the 'switch' statement that allows for a series of logical test and if none of those specific test has been passed takes a default action.

               

              You need to put the script in the 'Custom keystroke script'.

               

              if (!event.willCommit) {
              var M1Exp = this.getField("M1 Exp");

              if(event.changeEx == "January") {
              M1Exp.value = "1/31/10";
              } else if(event.changeEx == "February") {
              M1Exp.value = "2/28/10";
              } else if(event.changeEx == "March") {
              M1Exp.value = "3/31/10";
              } else if(event.changeEx == "April") {
              M1Exp.value = "4/30/10";
              } else if(event.changeEx == "May") {
              M1Exp.value = "5/31/10";
              } else if(event.changeEx == "June") {
              M1Exp.value = "6/30/10";
              }else if(event.changeEx == "July") {
              M1Exp.value = "7/31/10";
              } else if(event.changeEx == "August") {
              M1Exp.value = "8/31/10";
              } else if(event.changeEx == "September") {
              M1Exp.value = "9/30/10";
              }else if(event.changeEx == "October") {
              M1Exp.value = "10/31/10";
              }else if(event.changeEx == "November") {
              M1Exp.value = "11/30/10";
              }else if(event.changeEx == "December") {
              M1Exp.value = "12/31/10";
              }else{
              // all other selections
              M1Exp.value = "";
              }

              } // end not will commit

               

               

               

              You will also need to use the 'event' object's 'changeEx' property.

               

               

              If you do not need the selected text, by setting the export value to the expiration date your script could be:

               

              if (!event.willCommit) {
              this.getField("M1 Exp").value = event.changeEx;
              }

              • 4. Re: Need guidance for a Combo Box and Keystoke/Validate script
                try67 MVP & Adobe Community Professional

                Also, in the field's properties, under Options, tick "Commit selected value immediately".