Maximum Limit of checkbox clicked in horizontally and vertically for restriction

Basic data Matrix tutorial
NameFootballHockeyBadmintonCricketTennis
John Deo
Max Ruin
Arnold
Krish Star
John Mike
Alex John
My John Rob
Asruid
Tes Qry
Big John
Ronald
Recky
Kty
Bigy
Tade Row
Restrictions can be horizontally by limiting to maximum 2 games one student can join

Restrictions can be vertically by limiting each team to 5 members.

Maximum number of games allowed per student

var id=$(this).data('id');
var total_checked=  $(":checkbox:checked[data-id="+id+"]").length // reading number of games selected 
if(total_checked <3){
	// allow updating 
}

Maximum number of members in a team

var column_name=$(this).data('column_name');
var total_column_checked=  $(":checkbox:checked[data-column_name="+column_name+"]").length 
if(total_column_checked <6){
// allow updating
}
The Full code ( JQuery part is here )
<script>
$(document).ready(function() {
////////////////////
$('input[type="checkbox"]').change(function(){
var column_name=$(this).data('column_name');
var total_column_checked=  $(":checkbox:checked[data-column_name="+column_name+"]").length 
if(total_column_checked <6){
var id=$(this).data('id');
//var total_checked=  $("."+id+":checkbox:checked").length
var total_checked=  $(":checkbox:checked[data-id="+id+"]").length // reading number of games selected 
if(total_checked <3){
$.post( "data-matrixck.php", {"column_name":$(this).data('column_name'),"id":$(this).data('id')},function(return_data,status){
$("#msg_display").html(return_data);
});
}else{
$( this ).prop( "checked", false );	
$("#msg_display").html("You can't add more than 2 games");	
}
}else{
$( this ).prop( "checked", false );	
$("#msg_display").html("You can't add more than 5 memebers to  game");	
}

$("#msg_display").show();
setTimeout(function() { $("#msg_display").fadeOut('slow'); }, 5000);
});
//////////////////////////
////////////////
});
</script>
How to Install and test
  • Download the zip file at the end of this page.
  • Inside you will find sql_dump.text file to create tables in the database.
  • Open config-mysqli.php and enter your MySQL database login details.
  • Go to data-matrix-restriction.php page and check records


Your Rating




Post your comments , suggestion , error , requirements etc here .







Most Popular JQuery Scripts

1

Two dependant list boxes

2

Calendar with Date Selection

3

Data change by Slider

4

Show & Hide element
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer