Ver Mensaje Individual
  #12 (permalink)  
Antiguo 05/04/2010, 07:13
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 18 años, 2 meses
Puntos: 126
Respuesta: Un formularios con ayuda

Hola

A ver te he montado esto, pruebalo

Código Javascript:
Ver original
  1. <?php
  2. $razon = "Por que quiero";
  3. $cliente = 12;
  4. $calle = "Italia";
  5. $razon2 = "¿Por que no?";
  6. $cliente2 = 23;
  7. $calle2 = "La mia";
  8. ?>
  9. <html>
  10. <head>
  11. <script type="text/javascript">
  12. function Evento() {
  13. var trs = document.getElementById('tabla').getElementsByTagName('tr');
  14.     for(i=0; i < trs.length; i++) {
  15.         (function() {
  16. var elemento = trs[i];
  17. var nomevento = "click";
  18. var funcion = function() {
  19.     enviar_datos_cliente(this.id)
  20. }
  21.             if (elemento.attachEvent) {
  22.                     var f=function(){
  23.                         funcion.call(elemento,window.event);
  24.                     }
  25.                 elemento.attachEvent('on'+nomevento,f);
  26.                 return true;
  27.             }
  28.             else  
  29.                 if (elemento.addEventListener) {
  30.                         elemento.addEventListener(nomevento,funcion,false);
  31.                         return true;
  32.                     }
  33.             else
  34.                     return false;
  35.             }
  36.         )()
  37.         }
  38.  
  39. }
  40. window.onload = Evento;
  41. </script>
  42. </head>
  43. <body>
  44. Estos serán los datos que se enviarán al form
  45. <table border="1px" id="tabla">
  46. <tr>
  47. <th>Razon</th>
  48. <th>Cliente</th>
  49. <th>Calle</th>
  50. </tr>
  51. <tr id="0">
  52. <td id="R0"><?php echo $razon?></td>
  53. <td id="C0"><?php echo $cliente?></td>
  54. <td id="Ca0"><?php echo $calle?></td>
  55. </tr>
  56. <tr id="1">
  57. <td id="R1"><?php echo $razon2?></td>
  58. <td id="C1"><?php echo $cliente2?></td>
  59. <td id="Ca1"><?php echo $calle2?></td>
  60. </tr>
  61. </table>
  62. <script type="text/javascript">
  63. function enviar_datos_cliente(id){
  64.         window.opener.document.form1.camp1.value = document.getElementById('R'+id).innerHTML;        
  65.         window.opener.document.form1.camp2.value = document.getElementById('C'+id).innerHTML;            
  66.         window.opener.document.form1.camp3.value = document.getElementById('Ca'+id).innerHTML;
  67. self.close()
  68. }
  69. </script>
  70. </body>
  71. </html>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />