1
and a selection control for the checkbox so if it’s just a normal works but if you have type 2 option... one to choose 3 flavors and another to choose 2 flavors if I select first the 3 will normal and when I click to choose a tbm flavor more if I press on choose again the of 3 it continues functioning as if it were the of 2... plus the variable controler and the variable maximopermitido are with the correct values I do not understand why the if and Else does it... must be some storage n know... I will post the code
Obs: in imputs radios I select how many flavors to choose to be able to run the code I will post there now... thanks anyone who can help.
<script type="text/javascript">
$(document).ready(function(){
$('.tamanho_item').click(function (){
var vaaloridtamahoclick = $(this).data('idtaamanho');
var iddoitem = $(this).data('iddoitem');
var iddacategoria = $(this).data('iddacategoria');
$('input:checkbox').prop("checked", false);
$('#id_checkbox'+iddoitem).prop("checked", true);
$('#id_checkbox'+iddoitem).prop("disabled", true);
$.ajax({
url: '<?=$site;?>controlers/mostrar-meioameio.php',
method: 'post',
data: {'iditem' : iddoitem, 'idcat' : iddacategoria, 'idoption' : vaaloridtamahoclick, 'userid' : '<?=$getu;?>'},
success:function(data){
var maximopermitido = data;
var totalselecionagroup = data - 1;
if(data > 0){
$('#valortotalint_'+iddoitem).text(totalselecionagroup);
$("#mostrarmeioameio_"+iddoitem).show();
$('#cf_group_meioameio'+iddoitem+' input[type=checkbox]').click(function(){
var controle = $('#cf_group_meioameio' + iddoitem + ' input[type=checkbox]:checked').length;
//$('#valortotalint_'+iddoitem).text(controle + ' --> ' + maximopermitido);
if(controle > maximopermitido){
$(this).prop('checked', '');
$(this).addClass("tremer");
$('.hcinco').addClass("tremer");
setTimeout(function() {
$('input[type=checkbox]').removeClass("tremer");
$('.hcinco').removeClass("tremer");
}, 1000);
}
});
}else{
$("#mostrarmeioameio_"+iddoitem).hide();
}
}
});
});
});
</script>