Hola
A ver te he montado esto, pruebalo
Código Javascript
:
Ver original<?php
$razon = "Por que quiero";
$cliente = 12;
$calle = "Italia";
$razon2 = "¿Por que no?";
$cliente2 = 23;
$calle2 = "La mia";
?>
<html>
<head>
<script type="text/javascript">
function Evento() {
var trs = document.getElementById('tabla').getElementsByTagName('tr');
for(i=0; i < trs.length; i++) {
(function() {
var elemento = trs[i];
var nomevento = "click";
var funcion = function() {
enviar_datos_cliente(this.id)
}
if (elemento.attachEvent) {
var f=function(){
funcion.call(elemento,window.event);
}
elemento.attachEvent('on'+nomevento,f);
return true;
}
else
if (elemento.addEventListener) {
elemento.addEventListener(nomevento,funcion,false);
return true;
}
else
return false;
}
)()
}
}
window.onload = Evento;
</script>
</head>
<body>
Estos serán los datos que se enviarán al form
<table border="1px" id="tabla">
<tr>
<th>Razon</th>
<th>Cliente</th>
<th>Calle</th>
</tr>
<tr id="0">
<td id="R0"><?php echo $razon?></td>
<td id="C0"><?php echo $cliente?></td>
<td id="Ca0"><?php echo $calle?></td>
</tr>
<tr id="1">
<td id="R1"><?php echo $razon2?></td>
<td id="C1"><?php echo $cliente2?></td>
<td id="Ca1"><?php echo $calle2?></td>
</tr>
</table>
<script type="text/javascript">
function enviar_datos_cliente(id){
window.opener.document.form1.camp1.value = document.getElementById('R'+id).innerHTML;
window.opener.document.form1.camp2.value = document.getElementById('C'+id).innerHTML;
window.opener.document.form1.camp3.value = document.getElementById('Ca'+id).innerHTML;
self.close()
}
</script>
</body>
</html>
Suerte