0
Hello
I added an event change jQuery input field with date-Picker, for in every change already make the change in the BD. However, this input field is repeated for each user with the same name.
The code is working normally, makes the right changes and saves in the database for each user separately. However, when I look at the log I see that it fires to all registered users (even not affecting the others, only that it was modified).
$("input[name='last-day-training']").on('change', function() {
var id = $(this).attr('alt');
var last_day_training = $(this).val();
var data = {'key':'last-day-training','last_day':last_day_training,'user':id};
data = JSON.stringify(data);
$.ajax({
type : 'POST',
url : 'funcoes/_planejamento.php',
dataType : 'json',
data : {data:data},
success: function(data){
console.log(data);
if(data.sql=='ok'){
}else{
alert('Erro, por favor contate o administrador');
};
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
console.log(XMLHttpRequest);
console.log(textStatus);
console.log(errorThrown);
}
});
});
<input name="last-day-training" alt="<?php echo $l->id;?>" type="text" data-date-format="dd-mm-yyyy" data-date-viewmode="years" class="form-control date-picker">
What do you mean ? there are several input’s with the same name?
– Gabriel Rodrigues
Yes, because I have a list of users on the same screen, and for each user has this date-Picker input
– Geovane Krüger
Post html code also to facilitate understanding
– Gabriel Rodrigues
I did some tests here with more registered users and it’s actually not shooting for all users not. I just don’t understand why the log is showing up 3 times. Is it because of date-Picker, when updates?
– Geovane Krüger
It’s not date-Picker either, I tested it separately... I don’t know
– Geovane Krüger
Man
$("input[name='last-day-training']").on('change'...
will fire yes all the inputs that have the name equal to the last-day-training, a tip puts a different name p/ each input and be happy– SneepS NinjA