y el
js
Código Javascript
:
Ver original// JavaScript Document
var ordenar = '';
$(document).ready(function(){
// Llamando a la funcion de busqueda al
// cargar la pagina
filtrar()
var dates = $( "#del, #al" ).datepicker({
yearRange: "-50",
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
onSelect: function( selectedDate ) {
var option = this.id == "del" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
// filtrar al darle click al boton
$("#btnfiltrar").click(function(){ filtrar() });
// boton cancelar
$("#btncancel").click(function(){
$(".filtro input").val('')
$(".filtro select").find("option[value='0']").attr("selected",true)
filtrar()
});
// ordenar por
$("#data th span").click(function(){
var orden = '';
if($(this).hasClass("desc"))
{
$("#data th span").removeClass("desc").removeClass("asc")
$(this).addClass("asc");
ordenar = "&orderby="+$(this).attr("title")+" asc"
}else
{
$("#data th span").removeClass("desc").removeClass("asc")
$(this).addClass("desc");
ordenar = "&orderby="+$(this).attr("title")+" desc"
}
filtrar()
});
});
var fila= null;
function pulsar(obj, num_usuario) {
obj.style.background = 'orange';
if (fila != null && fila != obj)
fila.style.background = 'white';
fila = obj;
window.location ="menu1.php?id="+num_usuario;
}
function filtrar()
{
$.ajax({
data: $("#frm_filtro").serialize()+ordenar,
type: "POST",
dataType: "json",
url: "ajax.php?action=listar",
success: function(data){
var html_user ='' ;
if(data.length > 0){
$.each(data, function(i,item){
html_user += '<tr ondblclick="pulsar(this, ' + String.fromCharCode(39) + item.num_usuario + String.fromCharCode(39) + ');" >';
html_user += '<td >'+<input name="s" type="radio" value=""/>+'</td>';
html_user += '<td >'+item.num_usuario+'</td>';
html_user += '<td>'+item.telefono+'</td>';
html_user += '<td>'+item.nombre+' '+item.apellidos+'</td>';
html_user += '<td>'+item.poblacion+'</td>';
html_user += '</tr>';
});
}
if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
$("#data tbody").html(html_user);
}
});
}
Gracias de nuevo.