5 Replies Latest reply on Apr 16, 2013 10:30 AM by 8mittens

    Combo box selection, populates 2 text boxes

    8mittens

      I have multiple rows. I have a Combo Box "Part.1" Part.2" etc. going down the column. I intend the selction form a combo box of a row to fill the Description and Price of that row. ("Part.0" fills "Description.0" & "Price.0")

       

      I learned from 2 guides. The http://acrobatusers.com/tutorials/js_list_combo_livecycle1 & the http://acrobatusers.com/tutorials/change_another_field. Thanks for those guides, by the way.

       

      I'm using Acrobat 10.1.6 on the Mac (10.6.8).

       

      Tried many tactics to populate the fields and none have worked. I tried a suggestion I read in another thread to delete all script, save, close, start again. Still getting syntax errors. I'm using TextWrangler because the Acrobat window is too small for me to notice some differences in "," and "." sometimes.

       

      This is my latest attempt. When I paste it into Acrobat it highlights the "DWR1310B" line with a "syntax error: missing : after property id 16: at line 17"

      I don't understand the majority of the syntax errors it gives, and reading threads... lead me to think this version of Acrobat on a Mac is just too buggy to ever accomplish anything. What am I doing wrong? thank you

       

       

      var PartData=

      {

      "DB 1009P":        [ "Carotid Shunts","1,250.00" ],

      "DB 1009PT":     [ "Carotid Shunts","1,250.00" ],

      "DB 2000I":        [ "Carotid Shunts","1,250.00" ],

      "DB 5000IT":    [ "Carotid Shunts","1,250.00" ],

      "DBD 1009P":    [ "Doppler Carotid Shunts","1,500.00" ],

      "DBD 1009PT":     [ "Doppler Carotid Shunts","1,500.00" ],

      "DBD 2000I":    [ "Doppler Carotid Shunts","1,500.00" ],

      "DBD 5000IT":    [ "Doppler Carotid Shunts","1,500.00" ],

      "DWR 1310B":    [ "Doppler Carotid Shunts","1,500.00" ],

      "DWR 1409"        [ "Doppler Carotid Shunts","1,500.00" ],

      "DWR 1409SB"    [ "Doppler Carotid Shunts","1,500.00" ],

      "LS 1408":        [ "Doppler Carotid Shunts:,"1,250.00" ],

      "SCS 1014JT":    [ "Carotid Shunts","1,000.00" ],

      "SCS 1209BT":    [ "Carotid Shunts","1,000.00" ],

      "SDS 1014JT":    [ "Doppler Carotid Shunts","1,500.00" ],

      "SDS 1209":        [ "Doppler Carotid Shunts","1,250.00" ],

      "SDS 1209BT":    [ "Doppler Carotid Shunts","1,250.00" ],

      "Twin Pack":    [ "Carotid Shunts","750.00" ],

      "WR 1310B":        [ "Carotid Shunts","1,250.00" ],

      "WR 1409":        [ "Carotid Shunts","1,250.00" ],

      "WR 1409SB":    [ "Carotid Shunts","1,250.00" ],

      };

       

       

      function SetDescriptionValue()

      {

      if(event.willCommit)

          {

          var cRowName = event.target.name.split(".").shift();

       

          var 1st = PartData[event.value];

       

          if

          this.getField(cRowName + "Description").setItems(1st);

          else

              {

              this.getField(cRowName + "Description").clearItems();

              }

          }

      };

       

      function SetPriceValue()

      {

      if(event.willCommit)

          {

          var cRowName = event.target.name.split(".").shift();

       

          var 2nd = PartData[event.value];

       

          if

          this.getField(cRowName + "Price").setItems(2nd);

          else

              {

              this.getField(cRowName + "Price").clearItems();

              }

          }

       

      };

        • 1. Re: Combo box selection, populates 2 text boxes
          George_Johnson MVP & Adobe Community Professional

          I haven't looked at all of that, but noticed that this one is wrong:

           

          "LS 1408": [ "Doppler Carotid Shunts:,"1,250.00" ],

           

          "LS 1408": [ "Doppler Carotid Shunts","1,250.00" ],

           

          Sometime the line number it reports isn't exactly where you'll find the problem.

          • 2. Re: Combo box selection, populates 2 text boxes
            George_Johnson MVP & Adobe Community Professional

            Also, you are missing a colon after "DWR 1409"

            • 3. Re: Combo box selection, populates 2 text boxes
              George_Johnson MVP & Adobe Community Professional

              ...and the one after that...

              • 4. Re: Combo box selection, populates 2 text boxes
                George_Johnson MVP & Adobe Community Professional

                Varaible names (idnetifiers) in JavaScript cannot begin with digits, so your variables "1st" and "2nd" are not valid.

                 

                These lines don't make sense:

                 

                if

                    this.getField(cRowName + "Description").setItems(1st);

                    else

                 

                You probably meant to do something like:

                 

                 

                var first = PartData[event.value];

                 

                if (first && first[0]) {

                    this.getField(cRowName + "Description").value = first[0];

                } else {

                    this.getField(cRowName + "Description").value = "";

                }

                 

                 

                You can and probably should combine both functions into a single one so it can be called from the Keystroke event and set both the description and price fields at the same time.

                • 5. Re: Combo box selection, populates 2 text boxes
                  8mittens Level 1

                  Thank You! Good eyes. good eyes.

                  I do have difficulty seeing this itty bitty text.

                   

                  I also realized that for the new refined version, I should change the column of Desciption fields from Combo boxes to Text boxes. A better break from the old way I did the invoices, simplify, be true to the thread title (oops). ;P

                   

                  here is the latest attempt:

                  I think I need more RowName portions or have messed up the existing RowName portions... 0o

                   

                  var PartData=

                  {

                  "DB 1009P":         { "Description": "Carotid Shunts", "Price": "1,250" },

                  "DB 1009PT":      { "Description": "Carotid Shunts", "Price": "1,250" },

                  "DB 2000I":         { "Description": "Carotid Shunts", "Price": "1,250" },

                  "DB 5000IT":       { "Description": "Carotid Shunts", "Price": "1,250" },

                  "DBD 1009P":      { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "DBD 1009PT":    { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "DBD 2000I":       { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "DBD 5000IT":    { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "DWR 1310B":    { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "DWR 1409":       { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "DWR 1409SB":  { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "LS 1408":            { "Description": "Doppler Carotid Shunts", "Price": "1,250" },

                  "SCS 1014JT":     { "Description": "Carotid Shunts", "Price": "1,000" },

                  "SCS 1209BT":    { "Description": "Carotid Shunts", "Price": "1,000" },

                  "SDS 1014JT":     { "Description": "Doppler Carotid Shunts", "Price": "1,500" },

                  "SDS 1209":         { "Description": "Doppler Carotid Shunts", "Price": "1,250" },

                  "SDS 1209BT":    { "Description": "Doppler Carotid Shunts", "Price": "1,250" },

                  "Twin Pack":        { "Description": "Carotid Shunts", "Price": "750" },

                  "WR 1310B":       { "Description": "Carotid Shunts", "Price": "1,250" },

                  "WR 1409":          { "Description": "Carotid Shunts", "Price": "1,250" },

                  "WR 1409SB":     { "Description": "Carotid Shunts", "Price": "1,250" },

                  };

                   

                   

                  function SetFieldValues(cPartData)

                  {

                  this.getField(cRowName + "Description").value = PartData[cPartName].Description;

                  this.getField(cRowName + "Price").value = PartData[cPartName].Price;

                  }