Receive value Date in a modal and field date

3

I continue with the editions of registers on manners. Well, I find that when I pass the data to the modal I receive everything but the date that I do not get marked the BD.

Vereis I keep sending the data as always:

Adding the command id the almodal fields

<td class="tdfgaz" id="Fecha<?php echo $res['pedID']; ?>"><?php echo $res['Fecha']; ?></td>

I receive the data in the modal in this way
The fields that I can not get well are #eDate and #eVencimiento

<script>
        $(document).ready(function(){
            $(document).on('click', '.pedido', function(){
                var id=$(this).val();
                var Idp=$('#Idp'+id).text();
                var Estado=$('#select2-1'+id).children('span').first().text();
                var Numero=$('#Numero'+id).text();
                var Fecha=$('#Fecha'+id).text();
                var Vencimiento=$('#Vencimiento'+id).text();
                var Producto=$('#Producto'+id).text();
                var Total=$('#Total'+id).text();
                var Tipo=$('#select2-4'+id).children('span').first().text();
                var Ref=$('#select2-3'+id).children('span').first().text();

                $('#pedido').modal('show');
                $('#eIdp').val(Idp);
                $('#eNumero').val(Numero);
                $('#eFecha').val(Fecha);
                $('#eVencimiento').val(Vencimiento);
                $('#eProducto').val(Producto);
                $('#eTotal').val(Total);


                //alert(Estado);
                if(Estado == 'Pagado')
                  $('select#select2-1').val('1').trigger('change');
                else
                  $('select#select2-1').val('0').trigger('change');

                if(Tipo == 'Alquiler')
                  $('select#select2-4').val('1').trigger('change');
                if(Tipo == 'Comprada')
                  $('select#select2-4').val('2').trigger('change');
                if(Tipo == 'Exp.Compartida')
                  $('select#select2-4').val('3').trigger('change');
                if(Tipo == 'Alq. Opción a compra')
                  $('select#select2-4').val('5').trigger('change');


                if(Ref == 'Sin asignar')
                  $('select#select2-3').val('0').trigger('change');
                else
                  $('select#select2-3').val('').trigger('change');

                 });
             });
    </script>

And so I print the value in the values normally

<input type="date" class="form-control inputmiocont corpiii corpaddate" id="eFecha" name="eFecha">

Thanks !!

    
asked by Miguel 31.08.2018 в 07:19
source

1 answer

0

I could use the example, so you can see how it works.

var fecha = document.getElementById("Fecha25").textContent;
console.log('fecha '+fecha);
var res = fecha.split("/");
var fechaFormateada = res[2] + "-" + res[1] + "-" + res[0];
console.log('fecha formateada '+fechaFormateada);
document.getElementById('eFecha').value = fechaFormateada;
<span id="Fecha25">04/05/2018</span>
<br />
<input type="date" id="eFecha" value='' />
    
answered by 31.08.2018 в 12:37