2014-01-09 38 views
0

我想插入數據到表格中時,複選框被選中,並刪除數據表格時,複選框未取消檢查ia使用此ajax代碼..是否有任何事件會滅火時複選框改變複選框uncheked插入數據到表格複選框檢查使用ajax更改

代碼:

<script type="text/javascript"> 
$(function() { 


//$(".tb11").click(function(){ 
$(document).on('click', '.clUname', function(event) 
{ 
//Save the link in a variable called element 

var element = $(this); 
var table = $('#selecttable').val(); 
//Find the id of the link that was clicked 
var del_id = element.attr("id"); 

//Built a url to send 
//var info = 'id=' + del_id,'&selecttable=' + table 
if(confirm("Are You Sure You Want Delete This Record.")) 
      { 

$.ajax({ 
    type: "POST", 
    url: "DeletePropertyGalleryData.php", 
     data: 
      { 
       id: del_id ,selecttable: table 

      }, 
    success: function(){ 

    } 
}); 

} 

return false; 

}); 

}); 
</script> 
+1

搜索在谷歌事件複選框.. –

+0

我搜查,但沒有得到你用'的意思的任何解決方案 – dvirus

+0

沒得到任何solution'。複製粘貼上面的評論給了我十幾個結果。查看此https://www.google.co.in/search?q=checkbox+events&rlz=1C1AVNC_enIN561IN561&oq=checkbox+events&aqs=chrome..69i57&sourceid=chrome&espv=210&es_sm=122&ie=UTF-8#es_sm=122&espv=210&newwindow=1&q = checkbox + events + jquery –

回答

4

電平變化與嘗試也搭上覆選框事件

$(document).on('change', '.clUname', function(event) 
{ 

}); 
+0

實際上,我使用的是點擊功能多數民衆贊成爲什麼它不工作我的複選框cheked staus並未保留... – dvirus

0

複選框檢查,取消將調用的jQuery .change()事件。

如果.clUname是CheckBox類,然後使用下面的代碼:

jQuery('.clUname').change(function(){ 
    if(this.checked) { 
     // Insert Data 
    }else{ 
     // Delete Data 
    } 

})