title: Getting array of Values of Textboxes with the same class
body: <p>I setup custom CSS class for array of dynamic TextBoxes (inputs as HTML)</p>
  
  <p>so... now I need to get array of it :</p>
  
  <pre><code>&lt;input type="text" style="width: 50px;" class="DynamicTB" id="ctl00_ContentPlaceHolder1_GridView1_ctl02_id" readonly="readonly" value="1" name="ctl00$ContentPlaceHolder1$GridView1$ctl02$id"&gt;
  </code></pre>
  
  <p>sure client don't really knows the count of inputs. That's why I use class and here is what I'm trying to make :</p>
  
  <pre><code>        $.each( { id : $("input.DynamicTB").css("value") }, 
          function(id){
              CallPageMethod("SelectBook", success, fail, "id",id);
          });
  </code></pre>
  
  <p>I'm not sure if this $("input.DynamicTB").css("value") will works correct :( but</p>
  
  <ol>
  <li><p>How can I transfer whole array of values to SelectBook Method ? </p></li>
  <li><p>My javascript is bad and my debugger
  don't show me javascript errors but
  it just doesn't works because of
  something wrong with each.</p></li>
  </ol>
  
  <p>And ... finally I just need to get array of values of dynamic textboxes and transfer them to server side ... mt [WebMethode] can't see server side :(</p>
  
  <pre><code>[Web.Services.WebMethod]
  public static SelectBook(id : array) : string
  {
      id
  }
  </code></pre>
  
  <p>And sure I have no idea how can I use jQuery .live and binding here.</p>
  
  <p>ok... now problems solved , here is final way I do it XD </p>
  
  <p>Page :</p>
  
  <pre><code>      &lt;script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
        function CallPageMethod(methodName, onSuccess, onFail) 
        {
              var args = '';
              var l = arguments.length;
              if (l &gt; 3)
              {
                  for (var i = 3; i &lt; l - 1; i += 2) 
                  {
                      if (args.length != 0) args += ',';
                      args += '"' + arguments[i] + '":"' + arguments[i + 1] + '"';
                  }
              }
              var loc = window.location.href;
              loc = (loc.substr(loc.length - 1, 1) == "/") ? loc + "Report.aspx" : loc;
              $.ajax
              ({
                  type: "POST",
                  url: loc + "/" + methodName,
                  data: "{" + args + "}",
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: onSuccess,
                  fail: onFail
              });
          }
  
          function select() {
  
              var values = new Array();
              $("input.DynamicTB").each
                  (
                  function(i) {
                      values[i] = $(this).val();
                  }
                  );
  
                  var valuesG = new Array();
                  $("input.DynamicTBG").each
                  (
                  function(i) {
                      valuesG[i] = $(this).val();
                  }
                  );
  
              CallPageMethod("SelectBook", success, fail, "values", values, "valuesG", valuesG);
          }
  
    function success(response)
    {
      alert(response.d);
    }
  
    function fail(response)
    {
      alert("&amp;#1054;&amp;#1096;&amp;#1080;&amp;#1073;&amp;#1082;&amp;#1072;.");
    }
    &lt;/script&gt;
  </code></pre>
  
  <p>Adding Code :</p>
  
  <pre><code>  unless (GridView1.Rows.Count==0)
    {
      mutable ts=GridView1.Rows[0].Cells[0].Text.Split(':'); 
      mutable first=true;
      mutable cntrl=ts[1];
      foreach(index with row = GridView1.Rows[index] in [0..GridView1.Rows.Count-1])
      {
        unless (first) 
        ts=row.Cells[0].Text.Split(':');
        unless (ts.Length==1)
        {
        if (ts[1]==cntrl &amp;&amp; !first)
        {
          row.Cells[0].Text=ts[0];
        }
        else
        {
        row.Cells[0].Text="";
        row.Cells[0].Controls.Add
                  ({
                     def TB = TextBox(); TB.EnableViewState = false;
                     unless(row.Cells[0].Text == "&amp;nbsp;")
                     {
                       TB.Text = ts[0];
                     }
                     TB.Visible=true;
                     TB.ID="id"+TB.ClientID;
                     TB.Width = 50;
                     TB.CssClass="DynamicTB";
                     TB
                  });
        row.Cells[0].Controls.Add
                  ({
                     def TBQ = TextBox(); TBQ.EnableViewState = false;
                     unless(row.Cells[0].Text == "&amp;nbsp;")
                     {
                       TBQ.Text = cntrl;
                     }
                     TBQ.Width = 50;
                     TBQ.Visible=true;
                     TBQ.CssClass="DynamicTBG";
                     TBQ
                  });
      }
      when(first) first=false;
      cntrl=ts[1];
      }
      }
    }
  </code></pre>
  
  <p>Event Code :</p>
  
  <pre><code>    [Web.Services.WebMethod]
  public static SelectBook(values : string, valuesG : string) : string
  {
      def vals = values.Split(',');
      def valsG = valuesG.Split(',');
      SQLModule.UpdateAdvCode(vals, valsG)
  }
  </code></pre>
  
  <p>SQL Code :</p>
  
  <pre><code>    public static UpdateAdvCode(vals : array[string], valsG : array[string]) : string
      {   
          conn.Open();
          foreach(i in [0..vals.Length-1])
              unless (vals[i]=="" || vals[i]=="&amp;nbsp;")
              { 
                  def cmd = SqlCommand("UPDATE CfgGIS SET AdvCode='"+vals[i]+"' WHERE ID_GIS="+valsG[i], conn);
                  try
                  {
                      _=cmd.ExecuteNonQuery();
                  }
                  catch
                  {
                     | e is Exception =&gt; return e.ToString();
                  }
              }
          conn.Close();
          "Updated"
      }
  </code></pre>
  
  <p>and yeah ... I still need to fix adding code LOL</p>
  
  <p>by the way : The book is a lie and there is no book :P just save it's name from original manual</p>