2 Replies Latest reply on Apr 15, 2013 6:39 AM by Muthuraj Durairaj

    Get the value from dropdown list (selectedIndex) and text field -- not working

    Muthuraj Durairaj Level 1

      Hi All,

       

      I am trying to find and change by the values selected by user using dropdown and text field. Here is the code.

       

       

       

      ChangeRevDetails();
      function ChangeRevDetails(){
      
      
                var myDialog = app.dialogs.add({name:"Enter copyright information"});
      
      
      //    var monthlist = col1.dropdowns.add('myList', undefined, myList);
      
      
                var col1 = myDialog.dialogColumns.add();
                var col2 = myDialog.dialogColumns.add();
        
          col1.staticTexts.add({staticLabel:"Month:"});
                col1.staticTexts.add({staticLabel:"Year:"});
          col1.staticTexts.add({staticLabel:"Rev. no.:"});
          
          var myList = [ "January", "February",  "March", "April", "March", "April", "May", "June", "July", "August", "Sepetember", "October", "November", "December" ];
      
      
           var myMonth = col2.dropdowns.add({stringList:myList, selectedIndex:0, minWidth:100});//{minWidth:100});
           var myYear = col2.textEditboxes.add({editContents:"2013", minWidth:100});   
           var MyRev = col2.textEditboxes.add({minWidth:100});
      
      
          var RevMonth = (myList [myMonth.selectedIndex]);
          var RevYear = myYear.editContents;
          var RevNumber = MyRev.editContents;
          var RevToReplace1 = RevMonth +", "+ RevYear;
          var RevToReplace2 = RevMonth +", "+ RevYear + " Rev. " + RevNumber;
      
      
          var myResult = myDialog.show();
      
      
              if(myYear.editContents == "") //entry is "" 
              { 
              alert("Please enter some text into the contents field."); 
              ChangeRevDetails(); 
              }
              else if(myResult == true) //user entered datas 
              { 
      
      
                  alert (RevMonth);
                  alert (RevYear);
                  alert (RevNumber);
                  alert (RevToReplace1);
                  alert (RevToReplace2);
      
      
                  app.findGrepPreferences = NothingEnum.nothing;
                  app.changeGrepPreferences = NothingEnum.nothing;
      
      
                  // grep find/change
                  app.findGrepPreferences = app.changeGrepPreferences = null;       
                  app.findGrepPreferences.findWhat = "[\\l\\u]+?\\s?\\d{4},?\\s+[\\l\\u]+\\.*\\s+\\d+";
                  app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Back page"). paragraphStyles.item("Legal_7/9");
                  app.changeGrepPreferences.changeTo = RevToReplace1;
                  app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Back page"). paragraphStyles.item("Legal_7/9");
                  app.activeDocument.changeGrep();
      
      
                  app.findGrepPreferences = NothingEnum.nothing;
                  app.changeGrepPreferences = NothingEnum.nothing;
        
          } 
          else //implies user clicked cancel 
          { 
          myDialog.destroy(); 
          }
      
      
      }
      
      

       

       

      The problem is, it is not taking the value which the user selects from the dropdown and the text field. It takes the default value as "January" and the year is "2013" as both of these values are given as selectedIndex:0 and editContents:"2013". I have compared the coding with some other working scripts as well, but it is not working. I have added several alert boxes to check the value we get.

       

      Also, the find and change is also not working. Please help me on this. Thanks.

       

      Regards,

      Muthuraj. D

        • 1. Re: Get the value from dropdown list (selectedIndex) and text field -- not working
          -hans- Level 4

          Change the order for dialogresults:

           

          ...

          var myYear = col2.textEditboxes.add({editContents:"2013", minWidth:100});  
          var MyRev = col2.textEditboxes.add({minWidth:100});

           

           

           

           

           

          var myResult = myDialog.show();

           

           

              if(myYear.editContents == "") //entry is ""
              {
              alert("Please enter some text into the contents field.");
              ChangeRevDetails();
              }
              else if(myResult == true) //user entered datas
              {

           

          var RevMonth = (myList [myMonth.selectedIndex]);
          var RevYear = myYear.editContents;
          var RevNumber = MyRev.editContents;
          var RevToReplace1 = RevMonth +", "+ RevYear;

          var RevToReplace2 = RevMonth +", "+ RevYear + " Rev. " + RevNumber;

          ...

           

           

          didn't have a look for the find change problem

          • 2. Re: Get the value from dropdown list (selectedIndex) and text field -- not working
            Muthuraj Durairaj Level 1

            Hi Hans,

             

            Thanks for your help. It is working fine now until retriving data from the dialog box, however the find and change is not happening. I am trying to find out and will get back to you soon. Again, thanks for your great help. Have a good day.

             

            Regards,

            Muthuraj. D