0
How to recover a field’s "date" attribute from the database via jquery.
Today the system recovers the value(value) of the field, but now I also need to recover the date value of this field, as you ask (click here).
The purpose of this, is to make a comparison between the
value and . date-
In order to be able to make a condition to enable the save button, if any field of the form is changed and disable the button if nothing is changed in the form.
Follows as this the field in Html and Jquery:
<label for="descricao">Descrição</label>
<input class="span12" id="descricaoEditar" type="text" name="descricao" />
<input id="urlAtualEditar" type="hidden" name="urlAtual" value="" />
$(document).on('click', '.editar', function(event) {
$("#idEditar").val($(this).attr('idLancamento'));
$("#descricaoEditar").val($(this).attr('descricao'));
$("#descricaoEditar").val($(this).data('descricao'));
$("#fornecedorEditar").val($(this).attr('cliente'));
$("#valorEditar").val($(this).attr('valor'));
$("#vencimentoEditar").val($(this).attr('vencimento'));
$("#pagamentoEditar").val($(this).attr('pagamento'));
$("#formaPgtoEditar").val($(this).attr('formaPgto'));
$("#categoria_idEditar").val($(this).attr('categoria_id'));
$("#conta_idEditar").val($(this).attr('conta_id'));
$("#urlAtualEditar").val($(location).attr('href'));
var estornado = $(this).attr('estornado');
if(estornado == 1){
$("#estornadoEditar").attr('checked', true);
}
else{
$("#estornadoEditar").attr('checked', false);
}
var baixado = $(this).attr('baixado');
if(baixado == 1){
$("#pagoEditar").attr('checked', true);
$("#pagoEditar").attr('disabled', true);
$("#estornadoEditar").attr('disabled', false);
$("#divPagamentoEditar").show();
}
else{
$("#pagoEditar").attr('checked', false);
$("#pagoEditar").attr('disabled', false);
$("#estornadoEditar").attr('disabled', true);
$("#divPagamentoEditar").hide();
}
Renan, E to read the value saved in the database?
– Wagner Fillio
@Wagnerson to read from the database you will have to use your backend language (php, nodejs, c#, java, etc...). jquery does not do this, you will expose this database data with its direct backend language in the input element If it is PHP: When rendering the input, put the data-value="<attribute? php $variavelcomovalordobanco ? >" After that, by jquery vc will be able to get the data
– Renan Borges