Ver Mensaje Individual
  #8 (permalink)  
Antiguo 06/12/2011, 10:56
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Recorrer Array en PHP

bueno, seguimos con javascript,
si querés el innerHTML la función que pusiste es correcta, si solo queres el html generado tenes que usar
innerText --> IE, Opera Chrome Safari
ó su equivalente patra Firefox que es
textContent

ejemplo

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript">
  7. //<![CDATA[
  8.  
  9. function construye(){
  10.     var fila=document.getElementById("tabla").rows.length;
  11.     var columnas=document.getElementById("tabla").rows[0].cells.length;
  12.     var textos= 'CONTENIDO_TABLA|';
  13.  
  14.     for (var i=0; i<fila;i++)
  15.     {
  16.         for (var j=0; j<columnas;j++)
  17.         {
  18.             if (/Firefox/.test(navigator.userAgent)){
  19.          textos=textos+ document.getElementById('tabla').rows[i].cells[j].textContent + '|(' + i + ')(' + j + ')';
  20.         }else{
  21.         textos=textos+ document.getElementById('tabla').rows[i].cells[j].innerText + '|(' + i + ')(' + j + ')';
  22.        
  23.         }
  24.         }
  25.     }
  26.     alert (textos);
  27. }
  28.  
  29. //]]>
  30. </head>
  31. <table id="tabla" border="1">
  32. <tr>
  33. <td>
  34. celda 1 fila 1 <p>parrafo</p>
  35. </td>
  36. <td>
  37. celda 2 fila 1
  38. </td>
  39. <td>
  40. celda 3 fila 1
  41. </td>
  42. </tr>
  43. <tr>
  44. <td>
  45. celda 1 fila 2
  46. </td>
  47. <td>
  48. celda 2 fila 2
  49. </td>
  50. <td>
  51. celda 3 fila 2
  52. </td>
  53. </tr>
  54. <tr>
  55. <td>
  56. celda 1 fila 3
  57. </td>
  58. <td>
  59. celda 2 fila 3
  60. </td>
  61. <td>
  62. celda 3 fila 3
  63. </td>
  64. </tr>
  65. <p>
  66. <button onclick="construye();">recorrer tabla</button>
  67. </p>
  68. </body>
  69. </html>

Ahora resta pasar eso al php

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.