4 Replies Latest reply on Feb 13, 2011 3:35 PM by George_Johnson

    Scripting a textbox value change.

    Mr Paneser Level 1

      I thought I was doing really well with this, any ideas why this isn't working?

       

      I've got a combo box and an invisble text field with a pre-set value.  there are 5 choices in the combo.  If it is not changed then I do nothing.  If the first choice is picked I change the value in the text box and display it.  If any other value is picked I simple make the text box visible

       

      I've added the code which should be OK.  No errors are thrown up, but I haven't got a watch set up to check the values in "section"

       

      function add_verification_notice()

      {

       

          if (event.willCommit) return;

       

          // Get the value selected in the combo box

          var section = event.changeEx;

       

          // set a change message if required

          var message = "this message is good";

       

       

       

          // Exit if "Pick one" is selected

          if (section == 0) {

              return;

      }

       

          // Display the fields for the selected section

          if (section == 1) {

      getField("VerificationBox").value = message;

      }

       

      }

        • 1. Re: Scripting a textbox value change.
          gkaiseril MVP & Adobe Community Professional

          I would use the 'custom keystroke script' and the 'changeEx' property of the 'event.' object. You may want to set the 'commit selection immediately'.

          • 2. Re: Scripting a textbox value change.
            try67 MVP & Adobe Community Professional

            I think it more likely that the changeEx value is a string, not a number.

            • 3. Re: Scripting a textbox value change.
              Mr Paneser Level 1

              Apologies guys, but a newbe to programming in this lang

              Can you clarify points please

              • 4. Re: Scripting a textbox value change.
                George_Johnson MVP & Adobe Community Professional

                If that script is what you have for the custom Keystroke script of the combo box, it needs to be changed to:

                 

                 

                // Keystroke script for combo box

                (function () {

                 

                    if (event.willCommit) return;

                 

                    // Get the value selected in the combo box

                    var section = event.changeEx;

                 

                    // Exit if "Pick one" is selected

                    if (section == 0) {

                        return;

                    }

                 

                    // set a change message if required

                    var message = "this message is good";

                 

                    // Display themessage

                    if (section == 1) {

                        getField("VerificationBox").value = message;

                    }

                 

                })();

                 

                 

                 

                If that function is defined in a document-level JavaScript, the Keystroke script for the combo box would be:

                 

                // Call the function

                add_verification_notice();

                 

                 

                The first option sets up an anonymous function that calls itself. If you just define a function without calling it, nothing will happen.