Ver Mensaje Individual
  #13 (permalink)  
Antiguo 29/09/2012, 03:29
Avatar de satjaen
satjaen
 
Fecha de Ingreso: septiembre-2012
Ubicación: Jaén (Andalucía)
Mensajes: 893
Antigüedad: 11 años, 7 meses
Puntos: 10
Respuesta: Funcion en Paneles

Hola, he separado el index.php del js.js, pero no consigo llamar la funcion desde el panel en la pestaña Aparatos:

<li class="TabbedPanelsTab" tabindex="0" onclick="buscarAparatos();">Aparatos</li>


y el js


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.     filtrar()
  8.    
  9.     var dates = $( "#del, #al" ).datepicker({
  10.             yearRange: "-50",
  11.             defaultDate: "+1w",
  12.             changeMonth: true,
  13.             changeYear: true,
  14.             onSelect: function( selectedDate ) {
  15.                 var option = this.id == "del" ? "minDate" : "maxDate",
  16.                     instance = $( this ).data( "datepicker" ),
  17.                     date = $.datepicker.parseDate(
  18.                         instance.settings.dateFormat ||
  19.                         $.datepicker._defaults.dateFormat,
  20.                         selectedDate, instance.settings );
  21.                 dates.not( this ).datepicker( "option", option, date );
  22.             }
  23.     });
  24.    
  25.     // filtrar al darle click al boton
  26.     $("#btnfiltrar").click(function(){ filtrar() });
  27.    
  28.     // boton cancelar
  29.     $("#btncancel").click(function(){
  30.         $(".filtro input").val('')
  31.         $(".filtro select").find("option[value='0']").attr("selected",true)
  32.         filtrar()
  33.     });
  34.    
  35.     // ordenar por
  36.     $("#data th span").click(function(){
  37.         var orden = '';
  38.         if($(this).hasClass("desc"))
  39.         {
  40.             $("#data th span").removeClass("desc").removeClass("asc")
  41.             $(this).addClass("asc");
  42.             ordenar = "&orderby="+$(this).attr("title")+" asc"     
  43.         }else
  44.         {
  45.             $("#data th span").removeClass("desc").removeClass("asc")
  46.             $(this).addClass("desc");
  47.             ordenar = "&orderby="+$(this).attr("title")+" desc"
  48.         }
  49.         filtrar()
  50.     });
  51. });
  52.  
  53. var fila= null;
  54. function pulsar(obj, num_usuario) {
  55.   obj.style.background = 'orange';
  56.   if (fila != null && fila != obj)
  57.     fila.style.background = 'white';
  58.   fila = obj;
  59.  window.location ="menu1.php?id="+num_usuario;
  60. }
  61. function filtrar()
  62. {  
  63.     $.ajax({
  64.         data: $("#frm_filtro").serialize()+ordenar,
  65.         type: "POST",
  66.         dataType: "json",
  67.         url: "ajax.php?action=listar",
  68.             success: function(data){
  69.     var html_user ='' ;
  70.     if(data.length > 0){
  71.         $.each(data, function(i,item){
  72.        
  73.        
  74.          
  75.  html_user += '<tr ondblclick="pulsar(this, ' +  String.fromCharCode(39) + item.num_usuario + String.fromCharCode(39)  + ');" >';
  76.  html_user += '<td ><input name="s" type="radio" value=""/></td>';
  77.  html_user += '<td >'+item.num_usuario+'</td>';
  78.  html_user += '<td>'+item.telefono+'</td>';
  79.  html_user += '<td>'+item.nombre+' '+item.apellidos+'</td>';
  80.  html_user += '<td>'+item.poblacion+'</td>';
  81.  html_user += '</tr>';
  82.            
  83.                                  
  84.         });                    
  85.     }
  86.     if(html_user == '') html_user = '<tr><td colspan="4" align="center">No se encontraron registros..</td></tr>';
  87.     $("#data tbody").html(html_user);
  88. }
  89.  
  90.            
  91.       });
  92. }
  93. function createAjax(){
  94.    if (window.XMLHttpRequest)
  95.    {
  96.       xmlhttp=new XMLHttpRequest();
  97.    }
  98.    else
  99.    {
  100.       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  101.    }
  102. }
  103.  
  104. function buscarAparatos()
  105. {
  106.     createAjax();
  107.     xmlhttp.onreadystatechange=function()
  108.     {
  109.         if (xmlhttp.readyState==4 && xmlhttp.status==200)
  110.         {
  111.             document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
  112.         }
  113.     }
  114.     xmlhttp.open("GET","tabla_bus_avisos.php",true);
  115.     xmlhttp.send("ID=" + num_usuario);
  116. }


Por favor, ayudaaaaaaa.