I have a javascript function that should be executed when any of the two fields are made any kind of change.
At first only the #DataAbate field when a change is performed runs the script but I want the #AntiValue to also execute the function.
The question is how to make #DataAbate and #AntiValue without code redundancy.
$(document).ready(function () {
$("#DataAbate").change(function () {
$("#SequenciaInicial").empty();
$("#SequenciaFinal").empty();
$.ajax({
type: 'POST',
url: '@Url.Action("GetSequencia")',
dataType: 'json',
data: { dataAbate: $("#DataAbate").val() },
success: function (data) {
$.each(data, function (i, data) {
document.getElementById('NumeroLote').value = parseInt(data.NumeroLote) + 1;
document.getElementById('SequenciaInicial').value = parseInt(data.SequenciaFinal) + 1;
document.getElementById('SequenciaFinal').value = parseInt(data.SequenciaFinal) + parseInt($("#QuantidadeAnimais").val());
});
},
error: function (ex) {
alert('Falha ao buscar Proprietario.' + ex);
}
});
return false;
})
)}