How to retrieve from the database the "date" attribute of a field through jquery.
Today the system retrieves the value (value) of the field, but now I need to also retrieve the value of this same field, as asked #
How to retrieve from the database the "date" attribute of a field through jquery.
Today the system retrieves the value (value) of the field, but now I need to also retrieve the value of this same field, as asked #
You can pick up from
var valor = $("#estornadoEditar").val();
var descricao = $("#estornadoEditar").data("descricao");
To set the value $('seuelemento').attr('data-valor', valorquevcker);
To read the value $('seuelemento').attr('data-valor');
To get the value of the database in PHP and play in the view in your input would be something + - like this:
<input type="text" data-valor="<?php print $variavelcomovalordobanco ?>" />
Maybe the way to start the variable is not right, I'm not good at php, but it's something like that. You will have to make PHP print the value inside of the input, because the value that you get comes from the database
I think that enabling the button with "on change"
would suffice, but it follows a more elaborate form, in which if you return the initial value of the field, the button is disabled.
$('form input').each(function() {
$(this).data('value', $(this).val());
}).on('keyup', function() {
$('button').prop('disabled', true);
$('form input').each(function() {
if ($(this).val() != $(this).data('value')) $('button').prop('disabled', false);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><form><inputvalue="valor1">
<input value="valor2">
<input value="valor3">
<button disabled>Salvar</button>
</form>