2012-09-07 42 views
0

我有這顯示學生紀錄asp.Now該表中的列包含一個複選框,並檢查所有的複選框一個功能會在頂部提供了一個表中選擇在ASP中所有複選框功能。 如何使用JavaScript?工具使用JavaScript

+0

發表您的標記表和複選框。 –

回答

1

看到demo

$(function(){ 

    // add multiple select/deselect functionality 
    $("#selectall").click(function() { 
      $('.case').attr('checked', this.checked); 
    }); 

    // if all checkbox are selected, check the selectall checkbox 
    // and viceversa 
    $(".case").click(function(){ 

     if($(".case").length == $(".case:checked").length) { 
      $("#selectall").attr("checked", "checked"); 
     } else { 
      $("#selectall").removeAttr("checked"); 
     } 

    }); 
});​ 
+0

其實我的值是從一個數據庫,並在你的例子裏的值是靜態bound.Means對應於it.How獲得的該值的每個數據庫領域的一個新的複選框,將顯示? – Coder1010

+0

所以要在asp.net參見[此鏈接](http://lesson8.blogspot.in/2012/02/check-box-list-with-jquery.html) – Sender

0

定義鏈接的任何地方,抓住它的事件和使用checked屬性

<a href="#" rel="checkedBoxes">Check All Boxes</a> 
<a href="#" rel="uncheckedBoxes">Uncheck all Boxes</a> 

<script> 
    $(function() { 
     $("a[rel=checkedBoxes]").live("click", function(eV) { 
      eV.preventDefault(); 
      $("form input:checkbox").attr("checked", "checked"); 
     } 
     $("a[rel=uncheckedBoxes]").live("click", function(eV) { 
      eV.preventDefault(); 
      $("form input:checkbox").attr("checked", ""); 
     } 

    }); 
</script> 
+0

有腳本語法的一些錯誤。 。 – Coder1010