Search for orders between two dates

0

I am generating a prototype of a page of orders, some of the data of the order is the date which income, which I get in the following way in string

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //Enero es 0!

var yyyy = today.getFullYear();
if(dd<10){
    dd='0'+dd;
} 
if(mm<10){
    mm='0'+mm;
} 
var today = yyyy+'-'+mm+'-'+dd;

console.log(today);

And I add it to a table as follows

function mostrarListaPedidos(){
    $("#listaDePedidos").empty();
    var tabla="<table border='2px'>"
        tabla+="<tr><th>Número</th><th>Cliente</th><th>Dirección</th><th>Teléfono</th><th>Fecha de alta</th><th>Plato</th><th>Cantidad</th><th>Precio unitario</th><th>Estado</th><th>Precio total</th></tr>"
        for (var i=0;i<arregloPedidos.length;i++) {
            var pedido=arregloPedidos[i];
            var fila="<tr><td>"+pedido.numero+"</td><td>"+pedido.cliente+"</td><td>"+pedido.direccion+"</td><td>"+pedido.telefono+"</td><td>"+pedido.fechaDeAlta+"</td><td>"+pedido.plato+"</td><td>"+pedido.cantidad+"</td><td>$"+pedido.precioUnitario+"</td><td style='font-style: oblique;'>"+pedido.estado+"</td><td>$"+pedido.precioTotal+"</td></tr>"
            tabla+=fila
        }
        tabla+="</table>" 
        $("#listaDePedidos").append(tabla);
}

What I need to do is put two inputs of type date where you can choose an initial and final date, and search all the orders between those two dates entered, I have no idea how to do it, so I ask without having tried to do a code!

    
asked by JuanP 07.07.2017 в 15:39
source

1 answer

0

Hey friend then look for two controls because of type clear date is valid that the initial date is not greater than the final, having that validation then validates that you choose a date when you search and as such the consult you would have to go with the javascript and do the same when you insert the html.

 for (var i=0;i<arregloPedidos.length;i++) {
        var pedido=arregloPedidos[i];
       if( pedido.fecha => 'fecha inicial que viene' && pedido.fecha <= 'fecha final'){
           guardas esos valores en otro arreglo y construyes el html como ya sabes hacerlo.
       }

    }
    
answered by 07.07.2017 в 15:48