2 Replies Latest reply on Sep 16, 2014 2:10 PM by creativejoan0425

    About Script UI dialog Question

    creativejoan0425 Level 1

      I'm a new learner of Script UI dialog, I want to alert the edit text contents, if I change the first 4 rows to 1, 2, 3, 4

      then can I alert 1, 2, 3, 4, Echo, Foxtrot, Golf, Hotel. India, Juliet, Kilo, Lima, Mike, November, Oscar, Papa, Quebec, Romeo, Sierra, Tango, Uniform, Victor, Whiskey, X-ray, Yankee, Zulu"

       

       

       

      var call_codes = {"A": "Alpha", "B": "Bravo", "C": "Charlie", "D": "Delta", "E": "Echo", "F": "Foxtrot", "G": "Golf", "H": "Hotel", "I": "India",

      "J": "Juliet", "K": "Kilo", "L": "Lima", "M": "Mike", "N": "November", "O": "Oscar", "P": "Papa", "Q": "Quebec", "R": "Romeo", "S": "Sierra", "T":

      "Tango", "U": "Uniform", "V": "Victor", "W": "Whiskey", "X": "X-ray", "Y": "Yankee", "Z": "Zulu"};

      //~ var myChange =null;

      myChangeArray = [];

      myCol2Array = [];

      var rows = 14, number_of_codes = 0;

      for (var i in call_codes) number_of_codes++; // We need to know how many elements the object contains

      var w = new Window ("dialog");

      var group = w.add ("group {alignChildren: 'fill'}");

      var panel = group.add ("panel {orientation: 'row', alignChildren: 'top'}");

      var sbar = group.add ("scrollbar {preferredSize: [20, undefined], maxvalue: " + String (number_of_codes-rows) + "}");

      var col1 = panel.add ("group {orientation: 'column', margins: 3}");

      var col2 = panel.add ("group {orientation: 'column', alignChildren: 'fill', preferredSize: [150, undefined]}");

      var fields = {}, start = 0, stop = rows, n = -1;

      for (var i in call_codes){

      ++n;

      if (n >= start && n < stop){

      col1.add ("statictext", [0, 0, 20, 20], i);

      fields[n] = col2.add ("edittext", undefined, call_codes[i]);

      fields[n].label = i; // Add a label property that contains the letter

      myCol2 = fields[n].text;

      fields[n].onChange = function () {

          call_codes[this.label] = this.text;

          myChange = call_codes[this.label];

        myChangeArray.push(myChange);

        }

      myCol2Array.push(myCol2);

       

       

      } // When the edittext is changed, update the call_codes object

      }

      sbar.onChanging = function()

      {

      var start = Math.round (this.value); // Round the sbar's value

      var stop = start+rows, n = 0, r = -1;

      for (var i in call_codes)

      {

      n++;

      if (n > start && n <= stop)

      {

      ++r;

      col1.children[r].text = i; // Replace the contents of the statictext

      fields[r].text = call_codes[i]; // and the edittext controls

      fields[r].label = i; // and update each edittext's label

      }

      }

      }

       

       

      var myBottomGroup =  group.add ("group");

           myBottomGroup.alignChildren = ["fill","fill"];

            myBottomGroup.orientation = "column";

            myBottomGroup.add ("button", undefined, "OK");

            myBottomGroup.add ("button", undefined, "Cancel");

      var myWindow = w.show();

      if (myWindow == true){

      if (myChangeArray.toString().match(/./)){   

      for (var a = 0 ; a<myChangeArray.length; a++){

      alert(myChangeArray[a]);

      }

      for (var b= 0; b<myCol2Array.length; b++){

      alert(myCol2Array[b]);

      }

       

       

      }

      else {

          for (var b= 0; b<myCol2Array.length; b++){

      alert(myCol2Array[b]);

      }

              }

       

       

      }