Ver Mensaje Individual
  #7 (permalink)  
Antiguo 22/11/2011, 15:45
shekel
 
Fecha de Ingreso: octubre-2011
Mensajes: 45
Antigüedad: 12 años, 7 meses
Puntos: 0
Respuesta: Agrandar casilla de una tabla

Perdonad que reabra el tema.. pero tengo un problema, me crea la tabla y ya se modificarla y todo eso pero me ocurre algo "extraño". El codigo que estoy usando lo encontre por internet porque me parecia mas facil...


Código Javascript:
Ver original
  1. function MostrarCaja(num) {
  2. var raiz = document.getElementsByClassName("casilla") [num];
  3.  
  4. // creates a <table> element and a <tbody> element
  5. var tbl     = document.createElement("table");
  6. var tblBody = document.createElement("tbody");
  7.  
  8. // creating all cells
  9. for (var j = 1; j < 5; j++) {
  10.         // creates a table row
  11.         var row = document.createElement("tr");
  12.  
  13.         for (var i = 1; i < 3; i++) {
  14.                 // Create a <td> element and a text node, make the text
  15.                 // node the contents of the <td>, and put the <td> at
  16.                 // the end of the table row
  17.                 var cell = document.createElement("td");
  18.                 var cellText = document.createTextNode("cell");
  19.                
  20.                 cell.appendChild(cellText);
  21.                 row.appendChild(cell);
  22.         }
  23.  
  24.         // add the row to the end of the table body
  25.         tblBody.appendChild(row);
  26. }
  27. // put the <tbody> in the <table>
  28. tbl.appendChild(tblBody);
  29. // appends <table> into <body>
  30. raiz.appendChild(tbl);
  31. // sets the border attribute of tbl to 2;
  32. tbl.setAttribute("border", "1");
  33. tbl.setAttribute("width", "500");
  34. }

Este es el codigo php que genera la clase "casilla"

Código PHP:
Ver original
  1. echo '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="casilla" >';
  2. echo '  <tr>';
  3. echo '    <td width="05%" onclick="MostrarCaja(' .$NumeroFila .')">Nombre</td>';
  4. echo '    <td width="75%" onclick="MostrarCaja(' .$NumeroFila .')">Maria</td>';
  5. echo '  </tr>';
  6. echo '</table>';


Y aqui el resultado del antes y despues del click

ANTES:


DESPUES:




Se nota que al crear la tabla la celda donde pone "maria" se desplaza hasta el ancho de la tabla que creo..