10 Replies Latest reply on Jan 5, 2011 11:11 AM by George_Johnson

    Combo box resets itself

    gatzkerobgatzke Level 1

      When I select any item from my combo box it resets itself back to the first value. I have a custom calculation script under the calculation tab for the combo box:

       

      processTimeSelected();

       

      and the function is empty for now :

       

      processTimeSelected()

      {

           //empty

      }

       

      Why is the combo box resetting itself?

       

      Thanks.

        • 1. Re: Combo box resets itself
          try67 MVP & Adobe Community Professional

          You're not applying any value to the box, so why should it have one?

          • 2. Re: Combo box resets itself
            gatzkerobgatzke Level 1

            It already has values in it:

             

            4

            7

            10

             

            When I click "7" for eaxmple, it resets itself back to "4".

             

            I eventually plan on making this combo box do work, but in it's current state of insubordinance I'm having second thoughts..

             

            How can I implement a combo box that has a mind of its own?

            • 3. Re: Combo box resets itself
              try67 MVP & Adobe Community Professional

              You need to decide whether the value of this box should be set using the

              script, or should it be set manually.

              • 4. Re: Combo box resets itself
                gatzkerobgatzke Level 1

                It's already being set using script from another combo box:

                 

                Combo box #1 is clicked -> Combo box #2 gets values from a list

                 

                Combo box #2 is clicked -> Combobox #2 resets itself for no obvious reason

                 

                In short:

                 

                Combo box #1 obeys and acts appropriately, Combo box #2 does not..

                • 5. Re: Combo box resets itself
                  try67 MVP & Adobe Community Professional

                  The calculation script is meant to apply a value. I think you are misusing

                  it for another purpose, therefore this problem.

                  What are you trying to achieve with this script, exactly?

                  • 6. Re: Combo box resets itself
                    George_Johnson MVP & Adobe Community Professional

                    The way you've currently set up the calculation script for combo box 2 makes it not possible to manually select a value that's different from the one determined by the calculation. If you need the user to select a different value than the calculated value, you can modify the code so that it checks the value of event.source.name, and force a value only if it is combo box 1's name. Something like:

                     

                    // Calculate script for combo box

                    (function () {

                     

                        var f = getField("cb1");

                     

                        if (event.source && event.source.name === f.name) {

                     

                            event.value = f.value;

                     

                        }

                     

                    })();

                    • 7. Re: Combo box resets itself
                      gatzkerobgatzke Level 1

                      Perhaps there's an easier way to do what I want. Here's some code:

                       

                      var processTimeCombobox = {
                          0:    [    ["0","0"]    ],
                          1:    [    ["4","350"], ["7","275"], ["10","240"]    ],
                          2:    [    ["4","450"], ["7","375"], ["10","315"]    ],
                          3:    [    ["5","550"], ["7","550"], ["10","550"]    ],
                          4:    [    ["20","700"], ["25","640"]    ],
                          5:    [    ["4","350"], ["7","275"], ["10","240"]    ],
                          6:    [    ["20","1350"], ["25","1200"]    ]
                      };

                       

                      // This function is called from the first combo box
                      // It sets the values for the second combo box using
                      // the values above.
                      function serviceTypeSelected()
                      {

                           // processTime is the name of the second combo box
                          processTime.setItems(processTimeCombobox[event.value]);
                      }

                       

                      // This function is called from the second combo box
                      // It should set the price for a text box
                      function processTimeSelected()
                      {

                           // oFee is the name of the text box I want to populate with a new value
                          oFee.value = event.value;
                      }

                      • 8. Re: Combo box resets itself
                        George_Johnson MVP & Adobe Community Professional

                        It would be very helpful if you included which field event each script is attached to.

                        • 9. Re: Combo box resets itself
                          gatzkerobgatzke Level 1

                          All I require is:

                           

                          When the second combo box is clicked, it copies its value into a text box

                           

                          Let's ignore the first combo box - it's behaving properly.

                           


                          Here's the second combo box code:

                           

                          Under the "Calculate" tab -> "Custom calculation script"

                           

                               processTimeSelected();

                           

                          In "Document Javascripts"

                           

                               function processTimeSelected()

                               {

                                    oFee.value = event.value;

                               }

                           

                           

                          When I click the second combo box, it resets and the "oFee.value" does nothing..

                          • 10. Re: Combo box resets itself
                            George_Johnson MVP & Adobe Community Professional

                            I would urge you to instead set up the text field with a calculation script, rather than attempting to set it from an event of the second combo box.:

                             

                            event.value = getField("combo2").value;

                             

                             

                            If the user needs to be able to alter the value that gets calculated, you can use the approach I mentioned earlier. Also, checkk to make sure the field calculation order is correct.