Hi
We have a case with a client, we have a form that has a table in which a group of items that are in a sql table (limited to ten items) are added but there is another table that is dependent on the response to a field radio button, if the answer is 'Yes', it allows you to add items manually (they are not in the sql table), the total number of items in both tables cannot exceed 10.
The problem is that if the user adds 10 items in the first option, even if he deletes some items he cannot add in the second one since the code we place is not recognizing when the items are deleted.
We are using the following code:
$(document).ready(function () {
$('#Field27, #Field55').bind('keyup', function () {
console.log('aqui');
if ($('#Field27').val() != $('#Field55').val()) {
console.log('diferentes');
$('.Submit').prop("disabled", "disabled");
/*if ($('.warningText').length > 0 || $('.confirm input').val() == ''){
return;
} else {
$('<p class="warningText"><b id = "txt_color" >Las direcciones de correo no coinciden</b></p>').effect("highlight", {color:"#ff0000"}, 3000000).insertAfter('.confirm');
}*/
//$('<p class="warningText"><b id = "txt_color" >Las direcciones de correo no coinciden</b></p>').effect("highlight", {color:"#ff0000"}, 3000000).insertAfter('.confirm');
$("#Field58 p").css('color', 'red');
$("#Field58 p").html('Los correos no coinciden');
}
else{
console.log('iguales');
$('.warningText').remove();
$('.Submit').removeAttr('disabled');
$("#Field58 p").html('');
}
});
//$("#q36").attr('href', '#');
$("#q49").on('click', function(){
inputs = document.getElementsByClassName("propCount");
total = parseInt(inputs[0].value) + parseInt(inputs[1].value);
console.log(total);
//if($( "input:checked" ).val() == 'No'){
// total = total - 1;
//}
//if($("input[name='Field4']:checked").val() != undefined){
// total = total - 1;
//}
if($("#Field56-0:checked").val() == undefined){
total = total - 1;
}
console.log(total);
if(total > 9){
$("#q49").hide();
$("#q41").hide();
//$("#Field56-0").prop('disabled','disabled');
void(0);
}else{
$("#Field56-0").prop('disabled',false);
$("#q49").show();
$("#q41").show();
}
});
$("#q41").on('click', function(){
inputs = document.getElementsByClassName("propCount");
total = parseInt(inputs[0].value) + parseInt(inputs[1].value);
console.log(total);
if($("#Field56-0:checked").val() == undefined){
total = total - 1;
}
if(total == 10){
$("#q41").hide();
$("#q49").hide();
void(0);
}else{
$("#q49").show();
$("#q41").show();
}
});
$("#Field56-0").on('change',function(){
console.log("aqui 2");
inputs = document.getElementsByClassName("propCount");
total = parseInt(inputs[0].value) + parseInt(inputs[1].value);
if(total > 9){
$("#q49").hide();
$("#q41").hide();
}
if(total > 10){
$("#q41").hide();
$("#q49").hide();
$("#q42").hide();
}
});
$('a[title="Eliminar"]').on('click', function(){
console.log('press eliminar');
$("#Field56-0").prop('disabled',false);
});
});
Thanks for the help
Ricardo