2012-02-15 7 views
0

私はすべての行に行(同じ名前)に関連付けられたチェックボックスがあるテーブルを持っています。だから私は1つまたは複数のチェックボックスを選択して削除するユーザーにしたい。問題は、行が2つのクラスの情報に属していることです。だから私はクラス名1とクラス名2の行を持っています。そして、私は別のクラス名と同じクラスと他の行と他の行を有するjqueryでいくつかのTR内でTDの値を取得する方法

<TR valign=top name="rowSent1" style="background-color: #33CCCC" class="sent"> 
    <input type="hidden" value="messageRowSent1" name="message"/> 
    <TD width=12> 
     <div class="wpmd"> 
     <div align=center> 
     <font color="#FF0000" class="ws7"> 
      <input type="checkbox" name="rowSent1" onchange="analizeCheckBox()"/> // onchange to check inputs checked 
    </div> 
     </div> 
    </TD> 
    <TD width=147 > 
     <div class="wpmd"> 
     <div align=center> 
     <font color="#000000" class="ws7"><I><div class="info1">info1</div></I></font> 
    </div> 
     </div> 
    </TD> 
    <TD width=156 > 
     <div class="wpmd"> 
     <div align=center> 
      <font color="#000000" class="ws7"><I><div class="info2">info2</div></I></font> 
     </div> 
     </div> 
    </TD> 
</TR> 

function delete() { 
    // here i take all the checkbox checked 
    var checked = $("input[type=checkbox]:checked"); 
    // the number of checkbox checked 
    var nbChecked = checked.size(); 
    // just to the dialog 
    var b = nbChecked == 1 ? "notification" : "notifications"; 
    if (confirm('Are you sure to delete [' + nbChecked + '] ' + b + "?\nTake care.. you cannot resume the action!")) { 
     if (nbChecked > 1) { 
      // i want to generate a matrix. every row has an array of information. 
      var arr1; 
      // i take this code on web, but it doesn't work. I want to pur in sent all 
      // the tr with class sent and with input checkbox associated with it checked.  
      var sent = $('.mainTable').find("tr.sent input[type=checkbox]:checked").get(); 
      //HERE i want to iterate array sent to take all the information of td inside it and pur in arr1. 
      //HERE THE SAME DONE STILL NOW BUT CHANGING TR CLASS    
     } else { 
      // HERE IS SIMPLE 
     } 
    } 
}​ 

EDIT: 行のこの1クラス名sentと、これは今までdevelopeコードです。

私を助けることができますか?ありがとう!!!!

+0

は、あなたのテーブルのHTMLを投稿することができます。もちろん –

+0

!ちょっとだけ – JackTurky

+0

jpleryの編集pls – JackTurky

答えて

0

私はこれを作り、それが仕事だ:

function getMatrix(type){ 
       var array; 
       if(type=="sent"){ 
        array = $("tr.sent input[type=checkbox]:checked").toArray() 
       }else{ 
        array = $("tr.period input[type=checkbox]:checked").toArray() 
       } 
         var total = new Array(); 
         for(var i=0;i<array.length;i++){ 
          var tds = $(array[i]).parents("tr").children('td').toArray(); 
          var mess = $(array[i]).parents("tr").children('input[type=hidden]').val(); 
          var middle = new Array(); 
          middle.push(mess); 
          for(var j=0;j<tds.length;j++){ 
           var ii = $(tds[j]).text(); 
           middle.push($.trim(ii)); 
          } 
          total.push(middle); 
         } 
         return total; 
      } 
+0

私を救った!!!!!! – JackTurky

関連する問題