2011-06-23 2 views
1

グリッドには多くの行と2つの列があります。最後の行には、上記のチェックボックスのいずれも含まれていません。チェックすると、列の他のすべてのチェックボックスをオフにします。列の他のチェックボックスの1つがチェックされるとき、私はその列の上記のチェックボックスのどれもが自動的にチェックを外すことを望みません。私が持っているもの...問題は、この2枚目である、ここだ...私はnoobのグリッド内の '上記のどれもありません'チェックボックスは、列内の他のチェックボックスのチェックを外します。jquery

columnclear : function() { 
    // NoneClear -Columngrid 
    $(':checkbox[name*="ColumnClear"]').click(function() { 
     if (this.checked === true) { 
      var $table = $(this).closest("table"); 
      var col = $(this).closest("tr").children().index($(this).closest("td")); 
      var index = col+1; 
      $table.find("td:nth-child("+index+") input:checkbox") .attr("checked",false); 
      $table.find("tr:last td:nth-child("+index+") input:checkbox").attr("checked", true); 
     } 
    }); 
    $(':checkbox[name*!="ColumnClear"]').click(function() { 
     if (this.checked === true) { 
      var $table = $(this).closest("table"); 
      var col = $(this).closest("tr").children().index($(this).closest("td")); 
      var index = col+1; 
      $table.find("tr:last td:nth-child("+index+") input:checkbox").attr("checked", false); 
     } 
    }); 
} 

だHTMLの一部:各チェックボックスを想定し

<table summary="Which of the following products/systems does your company own and/or plan to purchase within the next 12 months? (Please select all that apply for each column)" class="mrQuestionTable" style=""> 
    <tr> 
    <td id="Cell.0.0"></td> 
    <td id="Cell.1.0" class="mrGridQuestionText" 
    <span class="mrQuestionText" style="color: #000000;;font-weight: bold;">Currently own</span> 
    </td> 
    <td id="Cell.2.0" class="mrGridQuestionText" 
    <span class="mrQuestionText" style="color: #000000;;font-weight: bold;">Plan to purchase</span> 
    </td> 
    </tr> 
    <tr> 
    <td id="Cell.0.1" class="mrGridCategoryText" 
    <span class="mrQuestionText" style="">Creative/Design software</span> 
    </td> 
    <td id="Cell.1.1" 
    <div></div> 
    <input type="checkbox" name="_QQ5_Qdesign_Qrating_Cown" id="_Q0_Q0_Q0_C0" class="mrMultiple" style="" value="own"></input> 
    </td> 
    <td id="Cell.2.1" style="text-Align: Center;vertical-align: Middle;border-color: black;border-style: Solid;border-width: 1px;"> 
    <div></div> 
    <input type="checkbox" name="_QQ5_Qdesign_Qrating_Cplan" id="_Q0_Q0_Q0_C1" class="mrMultiple" style="" value="plan"></input> 
    </td> 
    </tr> 
    <tr> 
    <td id="Cell.0.21" class="mrGridCategoryText" 
    <span class="mrQuestionText" style="">None of the above</span> 
    </td> 
    <td id="Cell.1.21" 
    <div></div> 
    <input type="checkbox" name="_QQ5_Qnon__ColumnClear1_Qrating_Cown" id="_Q0_Q20_Q0_C0" class="mrMultiple" style="" value="own"></input> 
    </td> 
    <td id="Cell.2.21" 
    <div></div> 
    <input type="checkbox" name="_QQ5_Qnon__ColumnClear1_Qrating_Cplan" id="_Q0_Q20_Q0_C1" class="mrMultiple" style="" value="plan"></input> 
    </td> 
    </tr> 
    </table> 
+0

があります。 2番目のイベントピース(from: ':checkbox [name *!= "ColumnClear"]')( "ColumnClear"という名前のチェックボックスの "none"をクリックしてfunction(){on}をチェックすることはできません。チェック可能でなければならず、その列の別のボックスがチェックされたときにチェックを外すことになります。 – adam

+0

最初のイベントは、上記のチェックボックスのいずれもチェックされていないときに、列の上記のチェックボックスのすべてをチェックしません。 – adam

答えて

2

はそれ自身のです「すべてをクリア」のチェックボックスにはname="ColumnClear"、2番目のブロックには:

$(':checkbox[name*!="ColumnClear"]').click(function() { 
    if (this.checked === true) { 
     var $table = $(this).closest("table").find(':checkbox[name*="ColumnClear"]').attr("checked", false); 
    } 
}); 
+0

これは私にとってはうまくいきません...すべてのチェックボックスは1つの大きなテーブルにあります – adam

+0

あなたはあなたの投稿を投稿できますか? HTML? –

+0

が上記の質問にいくつか追加されました – adam

関連する問題