Ver Mensaje Individual
  #2 (permalink)  
Antiguo 12/11/2012, 06:06
Avatar de Maganius
Maganius
 
Fecha de Ingreso: septiembre-2010
Mensajes: 310
Antigüedad: 13 años, 6 meses
Puntos: 10
Respuesta: No me hace la función cuando debe.

Asi te deberia de funcionar solo al clickear en la imagen

Código HTML:
Ver original
  1. <img id="filtrobutton" src="imagenes_menu/boton_buscar.jpg"  style="cursor:pointer;"/>

Código Javascript:
Ver original
  1. // JavaScript Document
  2.     var ordenar = '';
  3.     $(document).ready(function(){
  4.        
  5.         // Llamando a la funcion de busqueda al
  6.         // cargar la pagina
  7.      $("img#filtrobutton").click(function(){
  8.         filtrar()
  9.       })
  10.        
  11.         var dates = $( "#del, #al" ).datepicker({
  12.                 yearRange: "-50",
  13.                 defaultDate: "+1w",
  14.                 changeMonth: true,
  15.                 changeYear: true,
  16.                 onSelect: function( selectedDate ) {
  17.                     var option = this.id == "del" ? "minDate" : "maxDate",
  18.                         instance = $( this ).data( "datepicker" ),
  19.                         date = $.datepicker.parseDate(
  20.                             instance.settings.dateFormat ||
  21.                             $.datepicker._defaults.dateFormat,
  22.                             selectedDate, instance.settings );
  23.                     dates.not( this ).datepicker( "option", option, date );
  24.                 }
  25.         });
  26.         // ocultar div loading
  27.         $(".carga").hide();
  28.         // filtrar al darle click al boton
  29.         $("#btnfiltrar").click(function(){ filtrar() });
  30.        
  31.         // boton cancelar
  32.         $("#btncancel").click(function(){
  33.             $(".filtro input").val('')
  34.             $(".filtro select").find("option[value='0']").attr("selected",true)
  35.             filtrar()
  36.         });
  37.        
  38.         // ordenar por
  39.         $("#data th span").click(function(){
  40.             var orden = '';
  41.             if($(this).hasClass("desc"))
  42.             {
  43.                 $("#data th span").removeClass("desc").removeClass("asc")
  44.                 $(this).addClass("asc");
  45.                 ordenar = "&orderby="+$(this).attr("title")+" asc"    
  46.             }else
  47.             {
  48.                 $("#data th span").removeClass("desc").removeClass("asc")
  49.                 $(this).addClass("desc");
  50.                 ordenar = "&orderby="+$(this).attr("title")+" desc"
  51.             }
  52.             filtrar()
  53.         });
  54.     });
  55.      
  56.     var fila= null;
  57.     function pulsar(obj, num_usuario) {
  58.       obj.style.background = 'grey';
  59.       if (fila != null && fila != obj)
  60.         fila.style.background = 'white';
  61.       fila = obj;
  62.      window.location ="menu3.php?id="+num_usuario;
  63.     }
  64.     var fila= null;
  65.     function pulsar1(obj, num_aparato) {
  66.       obj.style.background = 'grey';
  67.       if (fila != null && fila != obj)
  68.         fila.style.background = 'white';
  69.       fila = obj;
  70.      window.location ="hist_apara.php?id="+num_aparato;
  71.     }
  72.     function filtrar()
  73.      
  74.     {
  75.            
  76.     * *     $.ajax({
  77.     * * * * data: $("#frm_filtro").serialize()+ordenar,
  78.     * * * * type: "POST",
  79.     * * * * dataType: "json",
  80.     * * * * url: "ajax.php?action=listar",
  81.     * * * * beforeSend:function(){
  82.             $('.carga').css('display','block');
  83.             $('.carga').html("<img src='imagenes_menu/ajax-loader4.gif' align='center' /><br />Cargando...");
  84.             },
  85.     * * * * success: function(data){
  86.             var html_user ='' ;
  87.             if(data.length > 0){
  88.             $.each(data, function(i,item){
  89.            
  90.            
  91.              
  92.      html_user += '<tr ondblclick="pulsar(this, ' +  String.fromCharCode(39) + item.num_usuario + String.fromCharCode(39)  + ');" >';
  93.      html_user += '<td ><input name="demo" type="radio" value="' + item.num_usuario + '"/></td>';
  94.      html_user += '<td id="row0" >'+item.num_usuario+'</td>';
  95.      html_user += '<td>'+item.telefono+'</td>';
  96.      html_user += '<td>'+item.nombre+' '+item.apellidos+'</td>';
  97.      html_user += '<td>'+item.poblacion+'</td>';
  98.      html_user += '</tr>';
  99.                
  100.                                      
  101.             });                    
  102.         }
  103.         if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  104.         $("#data tbody").html(html_user);
  105.         $('.carga').html('');
  106.     * *}
  107.      
  108.                
  109.           });
  110.     }
  111.      
  112.     function createAjax(){
  113.        if (window.XMLHttpRequest)
  114.        {
  115.           xmlhttp=new XMLHttpRequest();
  116.        }
  117.        else
  118.        {
  119.           xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  120.        }
  121.     }
  122.      
  123.     function buscarAparatos()
  124.     {
  125.         var num_usuario = 0;
  126.         var elements = document.getElementsByName('demo');
  127.        
  128.         for(var x=0;elements[x];x++){
  129.             if(elements[x].checked){
  130.                 num_usuario = elements[x].value;
  131.                 break;
  132.             }
  133.         }
  134.        
  135.         createAjax();
  136.         xmlhttp.onreadystatechange=function()
  137.         {
  138.             if (xmlhttp.readyState==4 && xmlhttp.status==200)
  139.             {
  140.                 document.getElementById("pestaña1").innerHTML=xmlhttp.responseText;
  141.             }
  142.         }
  143.        xmlhttp.open("GET","listado_aparatos.php?ID=" + num_usuario,true);
  144.        xmlhttp.send(null);
  145.     }