Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/01/2014, 15: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
Iluminar filas

Hola, por favor tengo este código que lista unas filas y lo que quiero es que se vayan iluminando al pasar con el raton pero no me sale.

Código Javascript:
Ver original
  1. <!--
  2. function ini() {
  3.    
  4.   tab=document.getElementById('tabl');
  5.   for (i=0; ele=tab.getElementsByTagName('td')[i]; i++) {
  6.     ele.onmouseover = function() {iluminar(this,true)}
  7.     ele.onmouseout = function() {iluminar(this,false)}
  8.   }
  9. }
  10.  
  11. function iluminar(obj,valor) {
  12.   fila = obj.parentNode;
  13.  
  14.     for (i=0; ele = fila.getElementsByTagName('td')[i]; i++)
  15.       ele.style.background = (valor) ? '#B9F8F8' : '';
  16. }
  17. -->
  18.  
  19.  
  20. function filtrar()
  21.  
  22. {
  23.  
  24. $.ajax({
  25. data: $("#frm_filtro").serialize()+ordenar,
  26. type: "POST",
  27. dataType: "json",
  28. url: "ajax.php?action=listar",
  29. beforeSend:function(){
  30. $('.carga1').css('display','block');
  31. $('.carga1').html("<img src='imagenes_menu/ajax-loader4.gif' align='center' /><br />Cargando...");
  32. },
  33. complete: function() {
  34. $(".carga1").show();
  35. $(".carga1").hide();
  36. },
  37. success: function(data){
  38. var html_user ='' ;
  39. if(data.length > 0){
  40. $.each(data, function(i,item){  
  41.  html_user += ' <body>';
  42.  html_user += '<form action="prod_sppb.php" method="post" name="nombreform">';
  43.  html_user += '<table id="tabl">';
  44.  html_user += '<tr bgcolor=#DFEBFF onMouseOver="ini()"  ondblclick="pulsar(this, '+ String.fromCharCode(39) + item.id_aviso +String.fromCharCode(39) + ');" >';
  45.  html_user += '<td style="'+item.style+'"><input name="demo"  type="checkbox" value="' + item.id_aviso + '"/></td>';
  46.  html_user += '<td  style="'+item.style+'">'+item.id_aviso+'</td>';
  47.  html_user += '<td  style="'+item.style+'">'+item.telefonos+'</td>';
  48.  html_user += '<td  style="'+item.style+'">'+item.name+' '+item.apellidos+'</td>';
  49.  html_user += '<td  style="'+item.style+'">'+item.calle+'</td>';
  50.  html_user += '<td  style="'+item.style+'">'+item.localidad+'</td>';
  51.  html_user += '<td  style="'+item.style+'">'+item.aparatos+'</td>';
  52.  html_user += '<td  style="'+item.style+'">'+item.marcas+'</td>';
  53.  html_user += '</tr>';
  54.  html_user += '</table>';
  55.  html_user += '</form>';
  56.  html_user += '</body>';

El error que me da:

Código HTML:
Ver original
  1. TypeError: tab is null
  2.    
  3. for (i=0; ele=tab.getElementsByTagName('td')[i]; i++) {


Gracias y feliz año.

Última edición por satjaen; 06/01/2014 a las 15:44